about summary refs log tree commit diff
path: root/pkgs/test/stdenv
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-12-15 13:27:54 +0100
committerGitHub <noreply@github.com>2022-12-15 13:27:54 +0100
commit84eebc0fe42522b4958d026ce9a50c17cad234b7 (patch)
tree9d8ffe8252e7635d05836a141af05f9f50db26ba /pkgs/test/stdenv
parentd6038881b8977fd6dd0a789385749ec3b5add361 (diff)
parent9b1e8d7267ad7999677ea1900a5613ee1f23d0fc (diff)
Merge pull request #205944 from ncfavier/structured-attrs-env
Diffstat (limited to 'pkgs/test/stdenv')
-rw-r--r--pkgs/test/stdenv/default.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/pkgs/test/stdenv/default.nix b/pkgs/test/stdenv/default.nix
index b27fc25356a52..5ff18298f217a 100644
--- a/pkgs/test/stdenv/default.nix
+++ b/pkgs/test/stdenv/default.nix
@@ -49,6 +49,7 @@ let
           declare -p string
           echo "env.string = $string"
           [[ $string == "testing-string" ]] || (echo "'\$string' was not 'testing-string'" && false)
+          [[ "$(declare -p string)" == 'declare -x string="testing-string"' ]] || (echo "'\$string' was not exported" && false)
           touch $out
         '';
       } // extraAttrs);
@@ -100,6 +101,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;