makeSetupHook: support depsTargetTargetPropagated

This commit is contained in:
Artturin 2022-12-30 22:14:00 +02:00
parent 84e37a10ec
commit 9a9c42e19f
4 changed files with 17 additions and 9 deletions

View file

@ -623,15 +623,24 @@ rec {
*/ */
makeSetupHook = makeSetupHook =
{ name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook" { name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook"
, deps ? [] , deps ? [ ]
, substitutions ? {} # hooks go in nativeBuildInput so these will be nativeBuildInput
, meta ? {} , propagatedBuildInputs ? [ ]
, passthru ? {} # these will be buildInputs
, depsTargetTargetPropagated ? [ ]
, meta ? { }
, passthru ? { }
, substitutions ? { }
}: }:
script: script:
runCommand name runCommand name
(substitutions // { (substitutions // {
inherit meta; inherit meta;
inherit depsTargetTargetPropagated;
propagatedBuildInputs =
# remove list conditionals before 23.11
lib.warnIf (!lib.isList deps) "deps argument to makeSetupHook must be a list. content: ${toString deps}"
propagatedBuildInputs ++ (if lib.isList deps then deps else [ deps ] );
strictDeps = true; strictDeps = true;
# TODO 2023-01, no backport: simplify to inherit passthru; # TODO 2023-01, no backport: simplify to inherit passthru;
passthru = passthru passthru = passthru
@ -642,8 +651,7 @@ rec {
('' (''
mkdir -p $out/nix-support mkdir -p $out/nix-support
cp ${script} $out/nix-support/setup-hook cp ${script} $out/nix-support/setup-hook
'' + lib.optionalString (deps != []) '' recordPropagatedDependencies
printWords ${toString deps} > $out/nix-support/propagated-build-inputs
'' + lib.optionalString (substitutions != {}) '' '' + lib.optionalString (substitutions != {}) ''
substituteAll ${script} $out/nix-support/setup-hook substituteAll ${script} $out/nix-support/setup-hook
''); '');

View file

@ -8,7 +8,7 @@
# imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput # imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput
makeSetupHook { makeSetupHook {
name = "wrap-lua-hook"; name = "wrap-lua-hook";
deps = makeWrapper; deps = [ makeWrapper ];
substitutions.executable = lua.interpreter; substitutions.executable = lua.interpreter;
substitutions.lua = lua; substitutions.lua = lua;
substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;

View file

@ -10,7 +10,7 @@
# Each of the substitutions is available in the wrap.sh script as @thingSubstituted@ # Each of the substitutions is available in the wrap.sh script as @thingSubstituted@
makeSetupHook { makeSetupHook {
name = "${octave.name}-pkgs-setup-hook"; name = "${octave.name}-pkgs-setup-hook";
deps = makeWrapper; deps = [ makeWrapper ];
substitutions.executable = octave.interpreter; substitutions.executable = octave.interpreter;
substitutions.octave = octave; substitutions.octave = octave;
} ./wrap.sh } ./wrap.sh

View file

@ -5,7 +5,7 @@
makePythonHook { makePythonHook {
name = "wrap-python-hook"; name = "wrap-python-hook";
deps = makeWrapper; deps = [ makeWrapper ];
substitutions.sitePackages = python.sitePackages; substitutions.sitePackages = python.sitePackages;
substitutions.executable = python.interpreter; substitutions.executable = python.interpreter;
substitutions.python = python.pythonForBuild; substitutions.python = python.pythonForBuild;