writeShellApplication: optionally do not inherit PATH

This commit is contained in:
Andrea Ciceri
2025-02-16 07:49:10 +00:00
parent 3fb1837662
commit 82b26280e3
@@ -269,6 +269,12 @@ rec {
Type: AttrSet
*/
derivationArgs ? { },
/*
Whether to inherit the current `$PATH` in the script.
Type: Bool
*/
inheritPath ? true
}:
writeTextFile {
inherit name meta passthru derivationArgs;
@@ -289,7 +295,7 @@ rec {
runtimeEnv))
+ lib.optionalString (runtimeInputs != [ ]) ''
export PATH="${lib.makeBinPath runtimeInputs}:$PATH"
export PATH="${lib.makeBinPath runtimeInputs}${lib.optionalString inheritPath ":$PATH"}"
'' + ''
${text}