1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
{ lib
, fetchFromGitHub
, perl
, buildPerlModule
, makeWrapper
, wrapGAppsHook
, withGtk3 ? false
, ffmpeg
, mpv
, wget
, xdg-utils
, youtube-dl
, yt-dlp
, TestPod
, Gtk3
}:
let
perlEnv = perl.withPackages (ps: with ps; [
AnyURIEscape
DataDump
Encode
FilePath
GetoptLong
HTTPMessage
JSON
JSONXS
LWPProtocolHttps
LWPUserAgentCached
Memoize
PathTools
ScalarListUtils
TermReadLineGnu
TextParsewords
UnicodeLineBreak
] ++ lib.optionals withGtk3 [
FileShareDir
]);
in
buildPerlModule rec {
pname = "pipe-viewer";
version = "0.4.8";
src = fetchFromGitHub {
owner = "trizen";
repo = "pipe-viewer";
rev = version;
hash = "sha256-bFbriqpy+Jjwv/s4PZmLdL3hFtM8gfIn+yJjk3fCsnQ=";
};
nativeBuildInputs = [ makeWrapper ]
++ lib.optionals withGtk3 [ wrapGAppsHook ];
buildInputs = [ perlEnv ]
# Can't be in perlEnv for wrapGAppsHook to work correctly
++ lib.optional withGtk3 Gtk3;
# Not supported by buildPerlModule
# and the Perl code fails anyway
# when Getopt::Long sets $gtk in Build.PL:
# Modification of a read-only value attempted at /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-perl5.34.0-Getopt-Long-2.52/lib/perl5/site_perl/5.34.0/Getopt/Long.pm line 585.
#buildFlags = lib.optional withGtk3 "--gtk3";
postPatch = lib.optionalString withGtk3 ''
substituteInPlace Build.PL --replace 'my $gtk ' 'my $gtk = 1;#'
'';
nativeCheckInputs = [
TestPod
];
dontWrapGApps = true;
postInstall = ''
cp -r share/* $out/share
'';
postFixup = ''
wrapProgram "$out/bin/pipe-viewer" \
--prefix PATH : "${lib.makeBinPath [ ffmpeg mpv wget youtube-dl yt-dlp ]}"
'' + lib.optionalString withGtk3 ''
# make xdg-open overrideable at runtime
wrapProgram "$out/bin/gtk-pipe-viewer" ''${gappsWrapperArgs[@]} \
--prefix PATH : "${lib.makeBinPath [ ffmpeg mpv wget youtube-dl yt-dlp ]}" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}"
'';
meta = with lib; {
homepage = "https://github.com/trizen/pipe-viewer";
description = "CLI+GUI YouTube Client";
license = licenses.artistic2;
maintainers = with maintainers; [ julm ];
platforms = platforms.all;
mainProgram = "pipe-viewer";
};
}
|