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
'';
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 ];
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
wantMan' = if wantMan == null then
builtins.any (p: lib.hasPrefix "share/man" p || lib.hasPrefix "share/doc" p) paths
separateMan' = if separateMan == null then
builtins.any (p: lib.hasPrefix "share/man" p) paths
else
wantMan;
separateMan;
separateDoc' = if separateDoc == null then
builtins.any (p: lib.hasPrefix "share/doc" p) paths
else
separateDoc;
in
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;
pathsToLink = paths;
configurePhase = ''
@@ -60,19 +64,6 @@
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) ''
tryLink() {
local input=$1