vapoursynth: Reformat and move according to guidelines

This commit is contained in:
Mikael Voss 2024-08-04 11:42:55 +02:00
parent 3d87b65e3f
commit 2c487f5608
7 changed files with 284 additions and 206 deletions

View File

@ -0,0 +1,80 @@
{
lib,
mkDerivation,
fetchFromGitHub,
makeWrapper,
runCommand,
python3,
vapoursynth,
qmake,
qtbase,
qtwebsockets,
}:
let
unwrapped = mkDerivation rec {
pname = "vapoursynth-editor";
version = "R19-mod-4";
src = fetchFromGitHub {
owner = "YomikoR";
repo = pname;
rev = lib.toLower version;
sha256 = "sha256-+/9j9DJDGXbuTvE8ZXIu6wjcof39SyatS36Q6y9hLPg=";
};
nativeBuildInputs = [ qmake ];
buildInputs = [
qtbase
vapoursynth
qtwebsockets
];
dontWrapQtApps = true;
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
'';
passthru = {
inherit withPlugins;
};
meta = with lib; {
description = "Cross-platform editor for VapourSynth scripts";
homepage = "https://github.com/YomikoR/VapourSynth-Editor";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.all;
};
};
withPlugins =
plugins:
let
vapoursynthWithPlugins = vapoursynth.withPlugins plugins;
in
runCommand "${unwrapped.name}-with-plugins"
{
nativeBuildInputs = [ makeWrapper ];
passthru = {
withPlugins = plugins': withPlugins (plugins ++ plugins');
};
}
''
mkdir -p $out/bin
for bin in vsedit{,-job-server{,-watcher}}; do
makeWrapper ${unwrapped}/bin/$bin $out/bin/$bin \
--prefix PYTHONPATH : ${vapoursynthWithPlugins}/${python3.sitePackages} \
--prefix LD_LIBRARY_PATH : ${vapoursynthWithPlugins}/lib
done
'';
in
withPlugins [ ]

View File

@ -1,7 +1,21 @@
{ lib, stdenv, fetchFromGitHub, pkg-config, autoreconfHook, makeWrapper
, runCommandCC, runCommand, vapoursynth, writeText, buildEnv
, zimg, libass, python3, libiconv, testers
, ApplicationServices
{
lib,
stdenv,
fetchFromGitHub,
pkg-config,
autoreconfHook,
makeWrapper,
runCommandCC,
runCommand,
vapoursynth,
writeText,
buildEnv,
zimg,
libass,
python3,
libiconv,
testers,
ApplicationServices,
}:
stdenv.mkDerivation rec {
@ -9,21 +23,34 @@ stdenv.mkDerivation rec {
version = "69";
src = fetchFromGitHub {
owner = "vapoursynth";
repo = "vapoursynth";
rev = "R${version}";
hash = "sha256-T2bCVNH0dLM9lFYChXzvD6AJM3xEtOVCb2tI10tIXJs=";
owner = "vapoursynth";
repo = "vapoursynth";
rev = "R${version}";
hash = "sha256-T2bCVNH0dLM9lFYChXzvD6AJM3xEtOVCb2tI10tIXJs=";
};
patches = [
./nix-plugin-loader.patch
];
patches = [ ./nix-plugin-loader.patch ];
nativeBuildInputs = [ pkg-config autoreconfHook makeWrapper ];
buildInputs = [
zimg libass
(python3.withPackages (ps: with ps; [ sphinx cython ]))
] ++ lib.optionals stdenv.isDarwin [ libiconv ApplicationServices ];
nativeBuildInputs = [
pkg-config
autoreconfHook
makeWrapper
];
buildInputs =
[
zimg
libass
(python3.withPackages (
ps: with ps; [
sphinx
cython
]
))
]
++ lib.optionals stdenv.isDarwin [
libiconv
ApplicationServices
];
enableParallelBuilding = true;
@ -35,8 +62,18 @@ stdenv.mkDerivation rec {
inherit python3;
withPlugins = import ./plugin-interface.nix {
inherit lib python3 buildEnv writeText runCommandCC stdenv runCommand
vapoursynth makeWrapper withPlugins;
inherit
lib
python3
buildEnv
writeText
runCommandCC
stdenv
runCommand
vapoursynth
makeWrapper
withPlugins
;
};
tests.version = testers.testVersion {
@ -58,10 +95,13 @@ stdenv.mkDerivation rec {
meta = with lib; {
broken = stdenv.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;
maintainers = with maintainers; [ rnhmjoj sbruder ];
homepage = "http://www.vapoursynth.com/";
license = licenses.lgpl21;
platforms = platforms.x86_64;
maintainers = with maintainers; [
rnhmjoj
sbruder
];
mainProgram = "vspipe";
};
}

View File

@ -0,0 +1,140 @@
{
lib,
python3,
buildEnv,
writeText,
runCommandCC,
stdenv,
runCommand,
vapoursynth,
makeWrapper,
withPlugins,
}:
plugins:
let
pythonEnvironment = python3.buildEnv.override { extraLibs = plugins; };
getRecursivePropagatedBuildInputs =
pkgs:
lib.flatten (
map (
pkg:
let
cleanPropagatedBuildInputs = lib.filter lib.isDerivation pkg.propagatedBuildInputs;
in
cleanPropagatedBuildInputs ++ (getRecursivePropagatedBuildInputs cleanPropagatedBuildInputs)
) pkgs
);
deepPlugins = lib.unique (plugins ++ (getRecursivePropagatedBuildInputs plugins));
pluginsEnv = buildEnv {
name = "vapoursynth-plugins-env";
pathsToLink = [ "/lib/vapoursynth" ];
paths = deepPlugins;
};
pluginLoader =
let
source = writeText "vapoursynth-nix-plugins.cpp" ''
#include <filesystem>
struct VSCore;
void VSLoadPluginsNix(void (*load)(VSCore *, const std::filesystem::path &), VSCore *core) {
${lib.concatMapStrings (
path: ''load(core, std::filesystem::u8path("${path}/lib/vapoursynth"));''
) deepPlugins}
}
'';
in
runCommandCC "vapoursynth-plugin-loader"
{
executable = true;
preferLocalBuild = true;
allowSubstitutes = false;
}
''
mkdir -p $out/lib
$CXX -std=c++17 -shared -fPIC ${source} -o "$out/lib/libvapoursynth-nix-plugins${ext}"
'';
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}
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 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
old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile)
new_rpath="''${old_rpath//"${vapoursynth}"/"$out"}"
patchelf \
--set-rpath "$new_rpath" \
--output $out/$binaryFile \
${vapoursynth}/$binaryFile
done
ln -s \
${pluginLoader}/lib/libvapoursynth-nix-plugins${ext} \
$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}
''

View File

@ -1,59 +0,0 @@
{ lib, mkDerivation, fetchFromGitHub, makeWrapper, runCommand
, python3, vapoursynth
, qmake, qtbase, qtwebsockets
}:
let
unwrapped = mkDerivation rec {
pname = "vapoursynth-editor";
version = "R19-mod-4";
src = fetchFromGitHub {
owner = "YomikoR";
repo = pname;
rev = lib.toLower version;
sha256 = "sha256-+/9j9DJDGXbuTvE8ZXIu6wjcof39SyatS36Q6y9hLPg=";
};
nativeBuildInputs = [ qmake ];
buildInputs = [ qtbase vapoursynth qtwebsockets ];
dontWrapQtApps = true;
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
'';
passthru = { inherit withPlugins; };
meta = with lib; {
description = "Cross-platform editor for VapourSynth scripts";
homepage = "https://github.com/YomikoR/VapourSynth-Editor";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.all;
};
};
withPlugins = plugins: let
vapoursynthWithPlugins = vapoursynth.withPlugins plugins;
in runCommand "${unwrapped.name}-with-plugins" {
nativeBuildInputs = [ makeWrapper ];
passthru = { withPlugins = plugins': withPlugins (plugins ++ plugins'); };
} ''
mkdir -p $out/bin
for bin in vsedit{,-job-server{,-watcher}}; do
makeWrapper ${unwrapped}/bin/$bin $out/bin/$bin \
--prefix PYTHONPATH : ${vapoursynthWithPlugins}/${python3.sitePackages} \
--prefix LD_LIBRARY_PATH : ${vapoursynthWithPlugins}/lib
done
'';
in
withPlugins []

View File

@ -1,123 +0,0 @@
{ lib, python3, buildEnv, writeText, runCommandCC, stdenv, runCommand
, vapoursynth, makeWrapper, withPlugins }:
plugins: let
pythonEnvironment = python3.buildEnv.override {
extraLibs = plugins;
};
getRecursivePropagatedBuildInputs = pkgs: lib.flatten
(map
(pkg: let cleanPropagatedBuildInputs = lib.filter lib.isDerivation pkg.propagatedBuildInputs;
in cleanPropagatedBuildInputs ++ (getRecursivePropagatedBuildInputs cleanPropagatedBuildInputs))
pkgs);
deepPlugins = lib.unique (plugins ++ (getRecursivePropagatedBuildInputs plugins));
pluginsEnv = buildEnv {
name = "vapoursynth-plugins-env";
pathsToLink = [ "/lib/vapoursynth" ];
paths = deepPlugins;
};
pluginLoader =
let
source = writeText "vapoursynth-nix-plugins.cpp" ''
#include <filesystem>
struct VSCore;
void VSLoadPluginsNix(void (*load)(VSCore *, const std::filesystem::path &), VSCore *core) {
${lib.concatMapStrings (
path: ''load(core, std::filesystem::u8path("${path}/lib/vapoursynth"));''
) deepPlugins}
}
'';
in
runCommandCC "vapoursynth-plugin-loader"
{
executable = true;
preferLocalBuild = true;
allowSubstitutes = false;
}
''
mkdir -p $out/lib
$CXX -std=c++17 -shared -fPIC ${source} -o "$out/lib/libvapoursynth-nix-plugins${ext}"
'';
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}
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 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
old_rpath=$(patchelf --print-rpath ${vapoursynth}/$binaryFile)
new_rpath="''${old_rpath//"${vapoursynth}"/"$out"}"
patchelf \
--set-rpath "$new_rpath" \
--output $out/$binaryFile \
${vapoursynth}/$binaryFile
done
ln -s \
${pluginLoader}/lib/libvapoursynth-nix-plugins${ext} \
$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}
''

View File

@ -20148,11 +20148,11 @@ with pkgs;
eigenmath = callPackage ../applications/science/math/eigenmath { };
vapoursynth = callPackage ../development/libraries/vapoursynth {
vapoursynth = callPackage ../by-name/va/vapoursynth/package.nix {
inherit (darwin.apple_sdk.frameworks) ApplicationServices;
};
vapoursynth-editor = libsForQt5.callPackage ../development/libraries/vapoursynth/editor.nix { };
vapoursynth-editor = libsForQt5.callPackage ../by-name/va/vapoursynth/editor.nix { };
vapoursynth-mvtools = callPackage ../development/libraries/vapoursynth-mvtools { };