linkIntoOwnPackage: handle share/man, share/doc consistently with nixpkgs

i.e. let stdenv move these to man/doc outputs, as appropriate
This commit is contained in:
2025-07-22 23:28:26 +00:00
parent 509208e305
commit 179c3a7ad7

View File

@@ -35,16 +35,20 @@
done done
''; '';
linkIntoOwnPackage = pkg: path: { wantMan ? null, ...}@args: let linkIntoOwnPackage = pkg: path: { separateDoc ? null, separateMan ? null, ...}@args: let
paths = if lib.isList path then path else [ path ]; paths = if lib.isList path then path else [ path ];
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else ""); suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
wantMan' = if wantMan == null then separateMan' = if separateMan == null then
builtins.any (p: lib.hasPrefix "share/man" p || lib.hasPrefix "share/doc" p) paths builtins.any (p: lib.hasPrefix "share/man" p) paths
else else
wantMan; separateMan;
separateDoc' = if separateDoc == null then
builtins.any (p: lib.hasPrefix "share/doc" p) paths
else
separateDoc;
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 separateMan' [ "man" ] ++ lib.optionals separateDoc' [ "doc" ];
inputs = pkg.all; inputs = pkg.all;
pathsToLink = paths; pathsToLink = paths;
configurePhase = '' configurePhase = ''
@@ -60,19 +64,6 @@
runHook postConfigure runHook postConfigure
''; '';
fixupPhase = ''
runHook preFixup
# move man-related outputs to man output
# TODO: doesn't nix do this for us automatically?
for item in share/doc share/man; do
if [ -e "$item" ]; then
moveToOutput "$item" "$man"
fi
done
runHook postFixup
'';
} // args) '' } // args) ''
tryLink() { tryLink() {
local input=$1 local input=$1