2021-08-31 09:13:13 +00:00
{ lib
, fetchFromGitHub
, perl
, buildPerlModule
, makeWrapper
, wrapGAppsHook
, withGtk3 ? false
, ffmpeg
, 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 = " p i p e - v i e w e r " ;
2022-09-09 18:53:43 +00:00
version = " 0 . 3 . 0 " ;
2021-08-31 09:13:13 +00:00
src = fetchFromGitHub {
owner = " t r i z e n " ;
repo = " p i p e - v i e w e r " ;
rev = version ;
2022-09-09 18:53:43 +00:00
hash = " s h a 2 5 6 - 2 K z o 7 N Y x A R P F u O i j w f 2 a 3 W Q x n N u m t K R i R h M h j r W A 4 G Y = " ;
2021-08-31 09:13:13 +00:00
} ;
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 ; #'
'' ;
checkInputs = [
TestPod
] ;
dontWrapGApps = true ;
postFixup = ''
wrapProgram " $ o u t / b i n / p i p e - v i e w e r " \
- - prefix PATH : " ${ lib . makeBinPath [ ffmpeg wget youtube-dl yt-dlp ] } "
'' + l i b . o p t i o n a l S t r i n g w i t h G t k 3 ''
2022-07-11 23:23:52 +00:00
# make xdg-open overrideable at runtime
2021-08-31 09:13:13 +00:00
wrapProgram " $ o u t / b i n / g t k - p i p e - v i e w e r " '' ${ gappsWrapperArgs [ @ ] } \
2022-07-11 23:23:52 +00:00
- - prefix PATH : " ${ lib . makeBinPath [ ffmpeg wget youtube-dl yt-dlp ] } " \
- - suffix PATH : " ${ lib . makeBinPath [ xdg-utils ] } "
2021-08-31 09:13:13 +00:00
'' ;
meta = with lib ; {
homepage = " h t t p s : / / g i t h u b . c o m / t r i z e n / p i p e - v i e w e r " ;
description = " C L I + G U I Y o u T u b e C l i e n t " ;
license = licenses . artistic2 ;
maintainers = with maintainers ; [ julm ] ;
platforms = platforms . all ;
} ;
}