In the following nix file, what is "withPlugins" called and what does it do? { lib,…
- User
In the following nix file, what is "withPlugins" called and what does it do?
{ 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.c" '' void VSLoadPluginsNix(void (*load)(void *data, const char *path), void *data) { {lib.concatMapStringsSep "" (path: "load(data, \"{path}/lib/vapoursynth");") deepPlugins} } ''; in runCommandCC "vapoursynth-plugin-loader" { executable = true; preferLocalBuild = true; allowSubstitutes = false; } '' mkdir -p CC -shared -fPIC out/lib/libvapoursynth-nix-plugins${ext}" '';
- Assistant
In the provided Nix file,
withPluginsserves as an argument to the function at the beginning of the file. It's a function defined in the scope of another function or derivation in Nix, and it's utilized to modify or extend the behavior of the software (in this case, VapourSynth) by dynamically including additional plugins.withPlugins = plugins': withPlugins (plugins ++ plugins');In this context, takes a list of plugin derivations () and returns a new version of itself with the passed plugins appended to the current list of plugins (). This enables composition, where plugins can be progressively added to a VapourSynth environment, enhancing its functionality with more features or filters.