From 15fa96fd94a320812aa0c6d20821b2ce931ab14d Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:09:04 +0100 Subject: [PATCH 1/7] vapoursynth: use new darwin sdk pattern --- pkgs/by-name/va/vapoursynth/package.nix | 27 +++++++++---------------- pkgs/top-level/all-packages.nix | 4 ---- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/pkgs/by-name/va/vapoursynth/package.nix b/pkgs/by-name/va/vapoursynth/package.nix index 88f341bfb699..fe2abaace074 100644 --- a/pkgs/by-name/va/vapoursynth/package.nix +++ b/pkgs/by-name/va/vapoursynth/package.nix @@ -12,9 +12,7 @@ zimg, libass, python3, - libiconv, testers, - ApplicationServices, }: stdenv.mkDerivation rec { @@ -33,21 +31,16 @@ stdenv.mkDerivation rec { autoreconfHook makeWrapper ]; - buildInputs = - [ - zimg - libass - (python3.withPackages ( - ps: with ps; [ - sphinx - cython - ] - )) - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - libiconv - ApplicationServices - ]; + buildInputs = [ + zimg + libass + (python3.withPackages ( + ps: with ps; [ + sphinx + cython + ] + )) + ]; enableParallelBuilding = true; doInstallCheck = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7f49620f8615..7ab0d078d7cd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9051,10 +9051,6 @@ with pkgs; eigen2 = callPackage ../development/libraries/eigen/2.0.nix { }; - vapoursynth = callPackage ../by-name/va/vapoursynth/package.nix { - inherit (darwin.apple_sdk.frameworks) ApplicationServices; - }; - vapoursynth-editor = libsForQt5.callPackage ../by-name/va/vapoursynth/editor.nix { }; vmmlib = callPackage ../development/libraries/vmmlib { From 199697f54ed4f1d78a0292c2796bb5ccdd46a101 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:52:53 +0100 Subject: [PATCH 2/7] vapoursynth: fix darwin build --- pkgs/by-name/va/vapoursynth/package.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/va/vapoursynth/package.nix b/pkgs/by-name/va/vapoursynth/package.nix index fe2abaace074..f2b57cddf493 100644 --- a/pkgs/by-name/va/vapoursynth/package.nix +++ b/pkgs/by-name/va/vapoursynth/package.nix @@ -43,7 +43,7 @@ stdenv.mkDerivation rec { ]; enableParallelBuilding = true; - doInstallCheck = true; + doInstallCheck = !stdenv.hostPlatform.isDarwin; passthru = rec { # If vapoursynth is added to the build inputs of mpv and then @@ -73,7 +73,7 @@ stdenv.mkDerivation rec { }; }; - postPatch = '' + postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' # Export weak symbol nixPluginDir to permit override of default plugin path sed -E -i \ -e 's/(VS_PATH_PLUGINDIR)/(nixPluginDir ? nixPluginDir : \1)/g' \ @@ -103,11 +103,10 @@ stdenv.mkDerivation rec { ''; meta = with lib; { - broken = stdenv.hostPlatform.isDarwin; # see https://github.com/NixOS/nixpkgs/pull/189446 for partial fix description = "Video processing framework with the future in mind"; homepage = "http://www.vapoursynth.com/"; license = licenses.lgpl21; - platforms = platforms.x86_64; + platforms = platforms.all; maintainers = with maintainers; [ rnhmjoj sbruder From 01cb82366fcb3e6104e6e9736aac9c5a78b65bfb Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:53:50 +0100 Subject: [PATCH 3/7] vapoursynth: reformat plugin interface --- .../va/vapoursynth/plugin-interface.nix | 129 +++++++++--------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/pkgs/by-name/va/vapoursynth/plugin-interface.nix b/pkgs/by-name/va/vapoursynth/plugin-interface.nix index 2716c27225cf..dcc7b6c909eb 100644 --- a/pkgs/by-name/va/vapoursynth/plugin-interface.nix +++ b/pkgs/by-name/va/vapoursynth/plugin-interface.nix @@ -51,77 +51,80 @@ let ext = stdenv.hostPlatform.extensions.sharedLibrary; in -runCommand "${vapoursynth.name}-with-plugins" - { - nativeBuildInputs = [ makeWrapper ]; - passthru = { - inherit python3; - inherit (vapoursynth) src version; - withPlugins = plugins': withPlugins (plugins ++ plugins'); - }; - } - '' - mkdir -p \ - $out/bin \ - $out/lib/pkgconfig \ - $out/lib/vapoursynth \ - $out/${python3.sitePackages} +if false then + vapoursynth +else + runCommand "${vapoursynth.name}-with-plugins" + { + nativeBuildInputs = [ makeWrapper ]; + passthru = { + inherit python3; + inherit (vapoursynth) src version; + withPlugins = plugins': withPlugins (plugins ++ plugins'); + }; + } + '' + mkdir -p \ + $out/bin \ + $out/lib/pkgconfig \ + $out/lib/vapoursynth \ + $out/${python3.sitePackages} - for textFile in \ - lib/pkgconfig/vapoursynth{,-script}.pc \ - lib/libvapoursynth.la \ - lib/libvapoursynth-script.la \ - ${python3.sitePackages}/vapoursynth.la - do - substitute ${vapoursynth}/$textFile $out/$textFile \ - --replace "${vapoursynth}" "$out" - done + for textFile in \ + lib/pkgconfig/vapoursynth{,-script}.pc \ + lib/libvapoursynth.la \ + lib/libvapoursynth-script.la \ + ${python3.sitePackages}/vapoursynth.la + do + substitute ${vapoursynth}/$textFile $out/$textFile \ + --replace "${vapoursynth}" "$out" + done - for binaryPlugin in ${pluginsEnv}/lib/vapoursynth/*; do - ln -s $binaryPlugin $out/''${binaryPlugin#"${pluginsEnv}/"} - done + for binaryPlugin in ${pluginsEnv}/lib/vapoursynth/*; do + ln -s $binaryPlugin $out/''${binaryPlugin#"${pluginsEnv}/"} + done - for pythonPlugin in ${pythonEnvironment}/${python3.sitePackages}/*; do - ln -s $pythonPlugin $out/''${pythonPlugin#"${pythonEnvironment}/"} - done + for pythonPlugin in ${pythonEnvironment}/${python3.sitePackages}/*; do + ln -s $pythonPlugin $out/''${pythonPlugin#"${pythonEnvironment}/"} + done - for binaryFile in \ - lib/libvapoursynth${ext} \ - lib/libvapoursynth-script${ext}.0.0.0 - do - old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile) - new_rpath="$old_rpath:$out/lib" - patchelf \ - --set-rpath "$new_rpath" \ - --output $out/$binaryFile \ - ${vapoursynth}/$binaryFile - patchelf \ - --add-needed libvapoursynth-nix-plugins${ext} \ - $out/$binaryFile - done - - for binaryFile in \ - ${python3.sitePackages}/vapoursynth${ext} \ - bin/.vspipe-wrapped - do + for binaryFile in \ + lib/libvapoursynth${ext} \ + lib/libvapoursynth-script${ext}.0.0.0 + do old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile) - new_rpath="''${old_rpath//"${vapoursynth}"/"$out"}" + new_rpath="$old_rpath:$out/lib" patchelf \ --set-rpath "$new_rpath" \ --output $out/$binaryFile \ ${vapoursynth}/$binaryFile - done + patchelf \ + --add-needed libvapoursynth-nix-plugins${ext} \ + $out/$binaryFile + done - ln -s ${nixPlugins} $out/lib/libvapoursynth-nix-plugins${ext} - ln -s ${vapoursynth}/include $out/include - ln -s ${vapoursynth}/lib/vapoursynth/* $out/lib/vapoursynth - ln -s \ - libvapoursynth-script${ext}.0.0.0 \ - $out/lib/libvapoursynth-script${ext} - ln -s \ - libvapoursynth-script${ext}.0.0.0 \ - $out/lib/libvapoursynth-script${ext}.0 + for binaryFile in \ + ${python3.sitePackages}/vapoursynth${ext} \ + bin/.vspipe-wrapped + do + old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile) + new_rpath="''${old_rpath//"${vapoursynth}"/"$out"}" + patchelf \ + --set-rpath "$new_rpath" \ + --output $out/$binaryFile \ + ${vapoursynth}/$binaryFile + done - makeWrapper $out/bin/.vspipe-wrapped $out/bin/vspipe \ - --prefix PYTHONPATH : $out/${python3.sitePackages} - '' + ln -s ${nixPlugins} $out/lib/libvapoursynth-nix-plugins${ext} + ln -s ${vapoursynth}/include $out/include + ln -s ${vapoursynth}/lib/vapoursynth/* $out/lib/vapoursynth + ln -s \ + libvapoursynth-script${ext}.0.0.0 \ + $out/lib/libvapoursynth-script${ext} + ln -s \ + libvapoursynth-script${ext}.0.0.0 \ + $out/lib/libvapoursynth-script${ext}.0 + + makeWrapper $out/bin/.vspipe-wrapped $out/bin/vspipe \ + --prefix PYTHONPATH : $out/${python3.sitePackages} + '' From c50074fffdf41f98a31a103893c972ba8ee4c986 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:01:21 +0100 Subject: [PATCH 4/7] vapoursynth: fix plugin interface on darwin --- pkgs/by-name/va/vapoursynth/plugin-interface.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/va/vapoursynth/plugin-interface.nix b/pkgs/by-name/va/vapoursynth/plugin-interface.nix index dcc7b6c909eb..a9abdd63abef 100644 --- a/pkgs/by-name/va/vapoursynth/plugin-interface.nix +++ b/pkgs/by-name/va/vapoursynth/plugin-interface.nix @@ -51,8 +51,13 @@ let ext = stdenv.hostPlatform.extensions.sharedLibrary; in -if false then - vapoursynth +if stdenv.hostPlatform.isDarwin then + vapoursynth.overrideAttrs (previousAttrs: { + pname = "vapoursynth-with-plugins"; + configureFlags = (previousAttrs.configureFlags or [ ]) ++ [ + "--with-plugindir=${pluginsEnv}/lib/vapoursynth" + ]; + }) else runCommand "${vapoursynth.name}-with-plugins" { From 31cb06a26a8218099b4b0890f383936a353dbfa7 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:50:00 +0100 Subject: [PATCH 5/7] vapoursynth-editor: fix darwin build --- pkgs/by-name/va/vapoursynth/editor.nix | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/va/vapoursynth/editor.nix b/pkgs/by-name/va/vapoursynth/editor.nix index 25d583148eb2..b426d111c799 100644 --- a/pkgs/by-name/va/vapoursynth/editor.nix +++ b/pkgs/by-name/va/vapoursynth/editor.nix @@ -1,5 +1,6 @@ { lib, + stdenv, mkDerivation, fetchFromGitHub, makeWrapper, @@ -23,6 +24,11 @@ let hash = "sha256-+/9j9DJDGXbuTvE8ZXIu6wjcof39SyatS36Q6y9hLPg="; }; + postPatch = '' + substituteInPlace pro/vsedit/vsedit.pro \ + --replace-fail "TARGET = vsedit-32bit" "TARGET = vsedit" + ''; + nativeBuildInputs = [ qmake ]; buildInputs = [ qtbase @@ -34,14 +40,25 @@ let preConfigure = "cd pro"; - preFixup = '' - cd ../build/release* - mkdir -p $out/bin - for bin in vsedit{,-job-server{,-watcher}}; do - mv $bin $out/bin - wrapQtApp $out/bin/$bin - done - ''; + preFixup = + '' + cd ../build/release* + mkdir -p $out/bin + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Applications + for bin in vsedit{,-job-server{,-watcher}}; do + mv $bin.app $out/Applications + makeQtWrapper $out/Applications/$bin.app/Contents/MacOS/$bin $out/bin/$bin + wrapQtApp $out/Applications/$bin.app/Contents/MacOS/$bin + done + '' + + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + for bin in vsedit{,-job-server{,-watcher}}; do + mv $bin $out/bin + wrapQtApp $out/bin/$bin + done + ''; passthru = { inherit withPlugins; From e7af7017b1db6a4ce7c7dde18d588464eb3bbbb3 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:50:09 +0100 Subject: [PATCH 6/7] vapoursynth-nnedi3: fix darwin build --- pkgs/by-name/va/vapoursynth-nnedi3/package.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/by-name/va/vapoursynth-nnedi3/package.nix b/pkgs/by-name/va/vapoursynth-nnedi3/package.nix index 1fe4b8597d72..a40d9742ba67 100644 --- a/pkgs/by-name/va/vapoursynth-nnedi3/package.nix +++ b/pkgs/by-name/va/vapoursynth-nnedi3/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitHub, + fetchpatch, autoreconfHook, pkg-config, vapoursynth, @@ -19,6 +20,14 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-jd/PCXhbCZGMsoXjekbeqMSRVBJAy4INdpkTbZFjVO0="; }; + patches = [ + (fetchpatch { + name = "build-fixes-for-aarch64-apple-silicon.patch"; + url = "https://github.com/dubhater/vapoursynth-nnedi3/commit/15c15080ed4406929aa0d2d6a3f83ca3e26bc979.patch"; + hash = "sha256-8gNj4LixfrGq0MaIYdZuwSK/2iyh1E9s/uuSBJHZwx8="; + }) + ]; + nativeBuildInputs = [ autoreconfHook pkg-config From 16e096e34e0e5a75923b1d4461d618bdea92a75e Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:50:16 +0100 Subject: [PATCH 7/7] vapoursynth-znedi3: fix darwin build --- pkgs/by-name/va/vapoursynth-znedi3/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/va/vapoursynth-znedi3/package.nix b/pkgs/by-name/va/vapoursynth-znedi3/package.nix index cd5b7f90fa29..fbde9b6d26ef 100644 --- a/pkgs/by-name/va/vapoursynth-znedi3/package.nix +++ b/pkgs/by-name/va/vapoursynth-znedi3/package.nix @@ -34,7 +34,7 @@ stdenv.mkDerivation { installPhase = '' runHook preInstall - install -D -t $out/lib/vapoursynth vsznedi3${stdenv.hostPlatform.extensions.sharedLibrary} + install -D -t $out/lib/vapoursynth vsznedi3.so install -D -m644 -t $out/share/nnedi3 nnedi3_weights.bin runHook postInstall