mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
Allow CLI to pass environment variables to FOD builder (#8830)
Add a new experimental `impure-env` setting that is a key-value list of environment variables to inject into FOD derivations that specify the corresponding `impureEnvVars`. This allows clients to make use of this feature (without having to change the environment of the daemon itself) and might eventually deprecate the current behaviour (pick whatever is in the environment of the daemon) as it's more principled and might prevent information leakage.
This commit is contained in:
parent
301623f3a3
commit
94e91566ed
8 changed files with 99 additions and 4 deletions
33
tests/functional/impure-env.sh
Normal file
33
tests/functional/impure-env.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
source common.sh
|
||||
|
||||
# Needs the config option 'impure-env' to work
|
||||
requireDaemonNewerThan "2.18.0pre20230816"
|
||||
|
||||
enableFeatures "configurable-impure-env"
|
||||
restartDaemon
|
||||
|
||||
varTest() {
|
||||
local var="$1"; shift
|
||||
local value="$1"; shift
|
||||
nix build --no-link -vL --argstr var "$var" --argstr value "$value" --impure "$@" --file impure-env.nix
|
||||
clearStore
|
||||
}
|
||||
|
||||
clearStore
|
||||
startDaemon
|
||||
|
||||
varTest env_name value --impure-env env_name=value
|
||||
|
||||
echo 'impure-env = set_in_config=config_value' >> "$NIX_CONF_DIR/nix.conf"
|
||||
set_in_config=daemon_value restartDaemon
|
||||
|
||||
varTest set_in_config config_value
|
||||
varTest set_in_config client_value --impure-env set_in_config=client_value
|
||||
|
||||
sed -i -e '/^trusted-users =/d' "$NIX_CONF_DIR/nix.conf"
|
||||
|
||||
env_name=daemon_value restartDaemon
|
||||
|
||||
varTest env_name daemon_value --impure-env env_name=client_value
|
||||
|
||||
killDaemon
|
Loading…
Add table
Add a link
Reference in a new issue