linkIntoOwnPackage: make pathsToLink introspectable/injectable by consumers

This commit is contained in:
2025-07-22 22:29:16 +00:00
parent 26469d5a11
commit a40a9dcfcc

View File

@@ -48,13 +48,20 @@
in in
runCommandLocalOverridable "${pkg.pname or pkg.name}-${suffix}" ({ runCommandLocalOverridable "${pkg.pname or pkg.name}-${suffix}" ({
outputs = [ "out" ] ++ lib.optionals wantMan' [ "man" ]; outputs = [ "out" ] ++ lib.optionals wantMan' [ "man" ];
pathsToLink = paths;
configurePhase = ''
runHook preConfigure
# all vars supplied by nix are str, so convert -> array
concatTo pathsToLink pathsToLink
runHook postConfigure
'';
} // args) '' } // args) ''
tryLink() { tryLink() {
local srcPath="$1/$2" local srcPath="$1/$2"
local dirName=$(dirname "$2") local dirName=$(dirname "$2")
test -e "$srcPath" && mkdir -p "$out/$dirName" && ln -s "$srcPath" "$out/$2" test -e "$srcPath" && mkdir -p "$out/$dirName" && ln -s "$srcPath" "$out/$2"
} }
for item in ${lib.escapeShellArgs paths}; do for item in "''${pathsToLink[@]}"; do
tryLink "${bin}" "$item" || tryLink "${bin}" "$item" ||
tryLink "${man}" "$item" || tryLink "${man}" "$item" ||
tryLink "${out}" "$item" || tryLink "${out}" "$item" ||