From 82b26280e3f2b931bfe8fa01c5adda20ba494ac1 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Sun, 16 Feb 2025 07:40:38 +0000 Subject: [PATCH] writeShellApplication: optionally do not inherit PATH --- pkgs/build-support/trivial-builders/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index be67b7b177ac..d2c200d19cec 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -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}