77# be nice to add the native GUI (and/or the GTK GUI) as an option too, but that
88# requires invoking the Xcode build system, which is non-trivial for now.
99
10- { stdenv , lib , fetchurl ,
10+ { stdenv , lib , fetchFromGitHub ,
1111 # Main build tools
1212 pkgconfig , autoconf , automake , libtool , m4 , lzma , python3 ,
1313 numactl ,
3030 # for now we disable GTK GUI support on Darwin. (It may be possible to remove
3131 # this restriction later.)
3232 useGtk ? ! stdenv . isDarwin , wrapGAppsHook ? null ,
33- intltool ? null ,
34- glib ? null ,
35- gtk3 ? null ,
36- libappindicator-gtk3 ? null ,
37- libnotify ? null ,
38- gst_all_1 ? null ,
39- dbus-glib ? null ,
40- udev ? null ,
41- libgudev ? null ,
42- hicolor-icon-theme ? null ,
33+ intltool ? null ,
34+ glib ? null ,
35+ gtk3 ? null ,
36+ libappindicator-gtk3 ? null ,
37+ libnotify ? null ,
38+ gst_all_1 ? null ,
39+ dbus-glib ? null ,
40+ udev ? null ,
41+ libgudev ? null ,
42+ hicolor-icon-theme ? null ,
4343 # FDK
4444 useFdk ? false , fdk_aac ? null
4545} :
4646
47- assert stdenv . isDarwin -> AudioToolbox != null && Foundation != null
48- && libobjc != null && VideoToolbox != null ;
47+ assert stdenv . isDarwin -> AudioToolbox != null
48+ && Foundation != null
49+ && libobjc != null
50+ && VideoToolbox != null ;
4951
5052stdenv . mkDerivation rec {
5153 pname = "handbrake" ;
5254 version = "1.3.2" ;
5355
54- src = fetchurl {
55- # 2020-05-05: NOTE: Thou fetching from GitHub, still fetchurl required,
56- # because this tarball has their "special" packaging and so
57- # internal "special" version information
58- url = ''https://github.com/HandBrake/HandBrake/releases/download/${ version } /HandBrake-${ version } -source.tar.bz2'' ;
59- sha256 = "0w7jxjrccvxp7g15dv0spildg5apmqp4gwbcqmg58va2gylynvzc" ;
56+ src = fetchFromGitHub {
57+ owner = "HandBrake" ;
58+ repo = "HandBrake" ;
59+ rev = version ;
60+ sha256 = "04z3hcy7m5yvma849rlrsx2wdqmkilkl1qds9yrzr2ydpw697f85" ;
61+ extraPostFetch = ''
62+ echo "DATE=$(date +"%F %T %z" -r $out/NEWS.markdown)" > $out/version.txt
63+ '' ;
6064 } ;
6165
66+ # we put as little as possible in src.extraPostFetch as it's much easier to
67+ # add to it here without having to fiddle with src.sha256
68+ # only DATE and HASH are absolutely necessary
69+ postPatch = ''
70+ cat >> version.txt <<_EOF
71+ HASH=${ src . rev }
72+ SHORTHASH=${ src . rev }
73+ TAG=${ version }
74+ URL=${ src . meta . homepage }
75+ _EOF
76+
77+ patchShebangs scripts
78+
79+ substituteInPlace libhb/module.defs \
80+ --replace /usr/include/libxml2 ${ libxml2 . dev } /include/libxml2
81+
82+ # Force using nixpkgs dependencies
83+ sed -i '/MODULES += contrib/d' make/include/main.defs
84+ sed -e 's/^[[:space:]]*\(meson\|ninja\|nasm\)[[:space:]]*= ToolProbe.*$//g' \
85+ -e '/ ## Additional library and tool checks/,/ ## MinGW specific library and tool checks/d' \
86+ -i make/configure.py
87+ '' ;
88+
6289 nativeBuildInputs = [
6390 pkgconfig autoconf automake libtool m4 python3
6491 ] ++ lib . optionals useGtk [ intltool wrapGAppsHook ] ;
@@ -73,34 +100,23 @@ stdenv.mkDerivation rec {
73100 gst_all_1 . gstreamer gst_all_1 . gst-plugins-base dbus-glib udev
74101 libgudev hicolor-icon-theme
75102 ] ++ lib . optional useFdk fdk_aac
76- ++ lib . optionals stdenv . isDarwin [ AudioToolbox Foundation libobjc VideoToolbox ]
103+ ++ lib . optionals stdenv . isDarwin [ AudioToolbox Foundation libobjc VideoToolbox ]
77104 # NOTE: 2018-12-27: Handbrake supports nv-codec-headers for Linux only,
78105 # look at ./make/configure.py search "enable_nvenc"
79- ++ lib . optional stdenv . isLinux nv-codec-headers ;
106+ ++ lib . optional stdenv . isLinux nv-codec-headers ;
80107
81- preConfigure = ''
82- patchShebangs scripts
83-
84- substituteInPlace libhb/module.defs \
85- --replace /usr/include/libxml2 ${ libxml2 . dev } /include/libxml2
86-
87- # Force using nixpkgs dependencies
88- sed -i '/MODULES += contrib/d' make/include/main.defs
89- sed -e 's/^[[:space:]]*\(meson\|ninja\|nasm\)[[:space:]]*= ToolProbe.*$//g' \
90- -e '/ ## Additional library and tool checks/,/ ## MinGW specific library and tool checks/d' \
91- -i make/configure.py
92- '' ;
108+ enableParallelBuilding = true ;
93109
94110 configureFlags = [
95111 "--disable-df-fetch"
96112 "--disable-df-verify"
97113 ( if useGtk then "--disable-gtk-update-checks" else "--disable-gtk" )
98114 ( if useFdk then "--enable-fdk-aac" else "" )
99115 ( if stdenv . isDarwin then "--disable-xcode" else "" )
100- ] ;
116+ ] ++ lib . optional ( stdenv . isx86_32 || stdenv . isx86_64 ) "--harden" ;
101117
102118 # NOTE: 2018-12-27: Check NixOS HandBrake test if changing
103- NIX_LDFLAGS = toString [
119+ NIX_LDFLAGS = [
104120 "-lx265"
105121 ] ;
106122
0 commit comments