1
0

pkgs/build-support: writePythonScript add runtimeInput option

This commit is contained in:
2025-09-21 16:58:15 +02:00
parent 6954e75a5c
commit 23629e0662

View File

@@ -1,6 +1,7 @@
{
python3,
writeTextFile,
makeWrapper,
runCommand,
lib,
}:
@@ -9,6 +10,7 @@
text,
runtimePackages ? ps: [],
pythonPackage ? python3,
runtimeInputs ? [],
meta ? {},
passthru ? {},
derivationArgs ? {},
@@ -18,13 +20,17 @@ let
pythonWithPackages = pythonPackage.withPackages runtimePackages;
in writeTextFile {
inherit
name
meta
passthru
derivationArgs
;
in runCommand name ({
passAsFile = [ "text" ] ++ (derivationArgs.passAsFile or []);
meta = {
mainProgram = name;
} // meta // (derivationArgs.meta or {});
passthru = passthru // (derivationArgs.passthru or {});
nativeBuildInputs = [ makeWrapper ] ++ (derivationArgs.nativeBuildInputs or []);
executable = true;
destination = "/bin/${name}";
allowSubstitutes = true;
@@ -34,4 +40,17 @@ in writeTextFile {
${text}
'';
}
} // (
builtins.removeAttrs derivationArgs [ "passAsFile" "meta" "passthru" "nativeBuildInputs" ]
))
''
mkdir -p $out/bin
target=$out/bin/${lib.escapeShellArg name}
cp "$textPath" "$target"
chmod +x "$target"
wrapProgram "$target" --prefix PATH : "${lib.makeBinPath runtimeInputs}"
''