From a64766913f229e5e63e5a0377df9b4837c87d36f Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 12 Jan 2024 13:30:36 -0800 Subject: [PATCH] writeShellApplication: Add `runtimeEnv` argument --- pkgs/build-support/trivial-builders/default.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index a8a07f6d071e..8a5fc288f1ec 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -269,6 +269,7 @@ rec { { name , text , runtimeInputs ? [ ] + , runtimeEnv ? null , meta ? { } , checkPhase ? null , excludeShellChecks ? [ ] @@ -283,7 +284,15 @@ rec { text = '' #!${runtimeShell} ${lib.concatMapStringsSep "\n" (option: "set -o ${option}") bashOptions} - '' + lib.optionalString (runtimeInputs != [ ]) '' + '' + lib.optionalString (runtimeEnv != null) + (lib.concatStrings + (lib.mapAttrsToList + (name: value: '' + ${lib.toShellVar name value} + export ${name} + '') + runtimeEnv)) + + lib.optionalString (runtimeInputs != [ ]) '' export PATH="${lib.makeBinPath runtimeInputs}:$PATH" '' + ''