1
0

pkgs/build-support: Add writePytonScript helper function

This commit is contained in:
2025-06-28 14:03:57 +02:00
parent 721f6681e1
commit eace2fabb2
4 changed files with 46 additions and 9 deletions

View File

@@ -0,0 +1,5 @@
final: prev:
{
writePythonScript = final.callPackage ./writePythonScript.nix {};
}

View File

@@ -0,0 +1,37 @@
{
python3,
writeTextFile,
lib,
}:
{
name,
text,
runtimePackages ? ps: [],
pythonPackage ? python3,
meta ? {},
passthru ? {},
derivationArgs ? {},
}:
let
pythonWithPackages = pythonPackage.withPackages runtimePackages;
in writeTextFile {
inherit
name
meta
passthru
derivationArgs
;
executable = true;
destination = "/bin/${name}";
allowSubstitutes = true;
preferLocalBuild = false;
text = ''
#!${lib.getExe pythonWithPackages}
${text}
'';
}