pkgs/build-support: writePythonScript add runtimeInput option
This commit is contained in:
@@ -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}"
|
||||
''
|
||||
|
Reference in New Issue
Block a user