btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / va / vapoursynth / package.nix
blob88f341bfb699c73731bcecca7b3f581f204e265c
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   pkg-config,
6   autoreconfHook,
7   makeWrapper,
8   runCommandCC,
9   runCommand,
10   vapoursynth,
11   buildEnv,
12   zimg,
13   libass,
14   python3,
15   libiconv,
16   testers,
17   ApplicationServices,
20 stdenv.mkDerivation rec {
21   pname = "vapoursynth";
22   version = "70";
24   src = fetchFromGitHub {
25     owner = "vapoursynth";
26     repo = "vapoursynth";
27     rev = "R${version}";
28     hash = "sha256-jkRjFKHNTekXluSKQ33QqsGRy7LKnkmG97U5WIjI6EM=";
29   };
31   nativeBuildInputs = [
32     pkg-config
33     autoreconfHook
34     makeWrapper
35   ];
36   buildInputs =
37     [
38       zimg
39       libass
40       (python3.withPackages (
41         ps: with ps; [
42           sphinx
43           cython
44         ]
45       ))
46     ]
47     ++ lib.optionals stdenv.hostPlatform.isDarwin [
48       libiconv
49       ApplicationServices
50     ];
52   enableParallelBuilding = true;
53   doInstallCheck = true;
55   passthru = rec {
56     # If vapoursynth is added to the build inputs of mpv and then
57     # used in the wrapping of it, we want to know once inside the
58     # wrapper, what python3 version was used to build vapoursynth so
59     # the right python3.sitePackages will be used there.
60     inherit python3;
62     withPlugins = import ./plugin-interface.nix {
63       inherit
64         lib
65         python3
66         buildEnv
67         runCommandCC
68         stdenv
69         runCommand
70         vapoursynth
71         makeWrapper
72         withPlugins
73         ;
74     };
76     tests.version = testers.testVersion {
77       package = vapoursynth;
78       # Check Core version to prevent false positive with API version
79       version = "Core R${version}";
80     };
81   };
83   postPatch = ''
84     # Export weak symbol nixPluginDir to permit override of default plugin path
85     sed -E -i \
86       -e 's/(VS_PATH_PLUGINDIR)/(nixPluginDir ? nixPluginDir : \1)/g' \
87       -e '1i\extern char const __attribute__((weak)) nixPluginDir[];' \
88       src/core/vscore.cpp
89   '';
91   postInstall = ''
92     wrapProgram $out/bin/vspipe \
93         --prefix PYTHONPATH : $out/${python3.sitePackages}
95     # VapourSynth does not include any plugins by default
96     # and emits a warning when the system plugin directory does not exist.
97     mkdir $out/lib/vapoursynth
98   '';
100   installCheckPhase = ''
101     runHook preInstallCheck
103     libv="$out/lib/libvapoursynth${stdenv.hostPlatform.extensions.sharedLibrary}"
104     if ! $NM -g -P "$libv" | grep -q '^nixPluginDir w'; then
105       echo "Weak symbol nixPluginDir is missing from $libv." >&2
106       exit 1
107     fi
109     runHook postInstallCheck
110   '';
112   meta = with lib; {
113     broken = stdenv.hostPlatform.isDarwin; # see https://github.com/NixOS/nixpkgs/pull/189446 for partial fix
114     description = "Video processing framework with the future in mind";
115     homepage = "http://www.vapoursynth.com/";
116     license = licenses.lgpl21;
117     platforms = platforms.x86_64;
118     maintainers = with maintainers; [
119       rnhmjoj
120       sbruder
121       snaki
122     ];
123     mainProgram = "vspipe";
124   };