pkgs/build-support: Add writePytonScript helper function
This commit is contained in:
5
pkgs/build-support/default.nix
Normal file
5
pkgs/build-support/default.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
final: prev:
|
||||
|
||||
{
|
||||
writePythonScript = final.callPackage ./writePythonScript.nix {};
|
||||
}
|
37
pkgs/build-support/writePythonScript.nix
Normal file
37
pkgs/build-support/writePythonScript.nix
Normal 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}
|
||||
'';
|
||||
}
|
Reference in New Issue
Block a user