summary refs log tree commit diff
path: root/pkgs/test/stdenv/default.nix
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-12-13 18:12:04 +0100
committerNaïm Favier <n@monade.li>2022-12-15 13:27:11 +0100
commite14de22618dc6c547f7c89f57eefe98e9e0bb8c4 (patch)
tree253336a7c9e450554a2cbabc414e496c6f3a2197 /pkgs/test/stdenv/default.nix
parent2a740527d6e6b139fa47adb40dce43dc3c371fd3 (diff)
downloadnixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.tar
nixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.tar.gz
nixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.tar.bz2
nixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.tar.lz
nixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.tar.xz
nixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.tar.zst
nixpkgs-e14de22618dc6c547f7c89f57eefe98e9e0bb8c4.zip
stdenv: handle `env` gracefully
Derivations not using `__structuredAttrs` should not attempt to set
environment variables from `env`.

Derivations using `__structuredAttrs` should fail if `env` is not
exportable.
Diffstat (limited to 'pkgs/test/stdenv/default.nix')
-rw-r--r--pkgs/test/stdenv/default.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkgs/test/stdenv/default.nix b/pkgs/test/stdenv/default.nix
index 08e8eed118f..ab5f98890bd 100644
--- a/pkgs/test/stdenv/default.nix
+++ b/pkgs/test/stdenv/default.nix
@@ -95,6 +95,25 @@ in
 {
   test-env-attrset = testEnvAttrset { name = "test-env-attrset"; stdenv' = bootStdenv; };
 
+  # Test compatibility with derivations using `env` as a regular variable.
+  test-env-derivation = bootStdenv.mkDerivation rec {
+    name = "test-env-derivation";
+    env = bootStdenv.mkDerivation {
+      name = "foo";
+      buildCommand = ''
+        mkdir "$out"
+        touch "$out/bar"
+      '';
+    };
+
+    passAsFile = [ "buildCommand" ];
+    buildCommand = ''
+      declare -p env
+      [[ $env == "${env}" ]]
+      touch "$out"
+    '';
+  };
+
   test-prepend-append-to-var = testPrependAndAppendToVar {
     name = "test-prepend-append-to-var";
     stdenv' = bootStdenv;