mpv: use waf from distribution and wafHook helper

This cleans up our dependency footprint by ensuring a consistent version, and
also avoids duplicating the logic for how to build a waf package by deferring to
the `wafHook` helper for the `configurePhase`, `buildPhase`, and `installPhase`.
This commit is contained in:
Benjamin Hipple 2020-02-02 14:06:35 -05:00
parent 9f61b23c01
commit 542d758956

View file

@ -1,5 +1,5 @@
{ config, stdenv, fetchurl, fetchFromGitHub, makeWrapper
, addOpenGLRunpath, docutils, perl, pkgconfig, python3, which
, addOpenGLRunpath, docutils, perl, pkgconfig, python3, wafHook, which
, ffmpeg_4, freefont_ttf, freetype, libass, libpthreadstubs, mujs
, nv-codec-headers, lua, libuchardet, libiconv ? null, darwin
@ -93,14 +93,6 @@ assert youtubeSupport -> available youtube-dl;
assert zimgSupport -> available zimg;
let
# Purity: Waf is normally downloaded by bootstrap.py, but
# for purity reasons this behavior should be avoided.
wafVersion = "2.0.9";
waf = fetchurl {
urls = [ "https://waf.io/waf-${wafVersion}"
"http://www.freehackers.org/~tnagy/release/waf-${wafVersion}" ];
sha256 = "0j7sbn3w6bgslvwwh5v9527w3gi2sd08kskrgxamx693y0b0i3ia";
};
luaEnv = lua.withPackages (ps: with ps; [ luasocket ]);
in stdenv.mkDerivation rec {
@ -121,7 +113,7 @@ in stdenv.mkDerivation rec {
NIX_LDFLAGS = optionalString x11Support "-lX11 -lXext "
+ optionalString stdenv.isDarwin "-framework CoreFoundation";
configureFlags = [
wafConfigureFlags = [
"--enable-libmpv-shared"
"--enable-manpage-build"
"--disable-libmpv-static"
@ -140,12 +132,8 @@ in stdenv.mkDerivation rec {
(enableFeature stdenv.isLinux "dvbin")
];
configurePhase = ''
python3 ${waf} configure --prefix=$out $configureFlags
'';
nativeBuildInputs = [
addOpenGLRunpath docutils makeWrapper perl pkgconfig python3 which
addOpenGLRunpath docutils makeWrapper perl pkgconfig python3 wafHook which
];
buildInputs = [
@ -189,9 +177,7 @@ in stdenv.mkDerivation rec {
enableParallelBuilding = true;
buildPhase = ''
python3 ${waf} build
'' + optionalString stdenv.isDarwin ''
postBuild = optionalString stdenv.isDarwin ''
python3 TOOLS/osxbundle.py -s build/mpv
'';
@ -204,9 +190,7 @@ in stdenv.mkDerivation rec {
--prefix PYTHONPATH : "${vapoursynth}/lib/${python3.libPrefix}/site-packages:$PYTHONPATH"
'';
installPhase = ''
python3 ${waf} install
postInstall = ''
# Use a standard font
mkdir -p $out/share/mpv
ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf