nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 115 lines 2.4 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 perl, 5 buildPerlModule, 6 makeWrapper, 7 wrapGAppsHook3, 8 withGtk3 ? false, 9 ffmpeg, 10 mpv, 11 wget, 12 xdg-utils, 13 yt-dlp, 14 TestPod, 15 Gtk3, 16}: 17let 18 perlEnv = perl.withPackages ( 19 ps: 20 with ps; 21 [ 22 AnyURIEscape 23 DataDump 24 Encode 25 FilePath 26 GetoptLong 27 HTTPMessage 28 JSON 29 JSONXS 30 LWPProtocolHttps 31 LWPUserAgentCached 32 Memoize 33 PathTools 34 ScalarListUtils 35 TermReadLineGnu 36 TextParsewords 37 UnicodeLineBreak 38 ] 39 ++ lib.optionals withGtk3 [ 40 FileShareDir 41 ] 42 ); 43in 44buildPerlModule rec { 45 pname = "pipe-viewer"; 46 version = "0.5.6"; 47 48 src = fetchFromGitHub { 49 owner = "trizen"; 50 repo = "pipe-viewer"; 51 rev = version; 52 hash = "sha256-ZcO07zDMXSFOWIC0XHqeqjgPJXzWWh8G2szTkvF8OjM="; 53 }; 54 55 nativeBuildInputs = [ makeWrapper ] ++ lib.optionals withGtk3 [ wrapGAppsHook3 ]; 56 57 buildInputs = [ 58 perlEnv 59 ] 60 # Can't be in perlEnv for wrapGAppsHook3 to work correctly 61 ++ lib.optional withGtk3 Gtk3; 62 63 # Not supported by buildPerlModule 64 # and the Perl code fails anyway 65 # when Getopt::Long sets $gtk in Build.PL: 66 # 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. 67 #buildFlags = lib.optional withGtk3 "--gtk3"; 68 postPatch = lib.optionalString withGtk3 '' 69 substituteInPlace Build.PL --replace 'my $gtk ' 'my $gtk = 1;#' 70 ''; 71 72 nativeCheckInputs = [ 73 TestPod 74 ]; 75 76 dontWrapGApps = true; 77 78 postInstall = '' 79 cp -r share/* $out/share 80 ''; 81 82 postFixup = '' 83 wrapProgram "$out/bin/pipe-viewer" \ 84 --prefix PATH : "${ 85 lib.makeBinPath [ 86 ffmpeg 87 mpv 88 wget 89 yt-dlp 90 ] 91 }" 92 '' 93 + lib.optionalString withGtk3 '' 94 # make xdg-open overrideable at runtime 95 wrapProgram "$out/bin/gtk-pipe-viewer" ''${gappsWrapperArgs[@]} \ 96 --prefix PATH : "${ 97 lib.makeBinPath [ 98 ffmpeg 99 mpv 100 wget 101 yt-dlp 102 ] 103 }" \ 104 --suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" 105 ''; 106 107 meta = with lib; { 108 homepage = "https://github.com/trizen/pipe-viewer"; 109 description = "CLI+GUI YouTube Client"; 110 license = licenses.artistic2; 111 maintainers = with maintainers; [ julm ]; 112 platforms = platforms.all; 113 mainProgram = "pipe-viewer"; 114 }; 115}