From 56605b468868b834e44a9700907b734428cb120a Mon Sep 17 00:00:00 2001 From: regnat Date: Thu, 20 May 2021 13:55:00 +0200 Subject: Make `nix-shell` support content-addressed derivations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve the derivation before trying to load its environment − essentially reproducing what the build loop does − so that we can effectively access our dependencies (and not just their placeholders). Fix #4821 --- tests/shell.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/shell.nix') diff --git a/tests/shell.nix b/tests/shell.nix index 24ebcc04c..53759f99a 100644 --- a/tests/shell.nix +++ b/tests/shell.nix @@ -1,6 +1,18 @@ -{ inNixShell ? false }: +{ inNixShell ? false, contentAddressed ? false }: -with import ./config.nix; +let cfg = import ./config.nix; in +with cfg; + +let + mkDerivation = + if contentAddressed then + args: cfg.mkDerivation ({ + __contentAddressed = true; + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + } // args) + else cfg.mkDerivation; +in let pkgs = rec { setupSh = builtins.toFile "setup" '' -- cgit v1.2.3 From 087c5f5325c46485a9bc5f8e7f2620af6bf6bf56 Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Mon, 5 Jul 2021 12:00:08 +0200 Subject: Fix devShell handling of env values including @ and % --- tests/shell.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/shell.nix') diff --git a/tests/shell.nix b/tests/shell.nix index 53759f99a..f174db583 100644 --- a/tests/shell.nix +++ b/tests/shell.nix @@ -34,6 +34,8 @@ let pkgs = rec { name = "shellDrv"; builder = "/does/not/exist"; VAR_FROM_NIX = "bar"; + ASCII_PERCENT = "%"; + ASCII_AT = "@"; TEST_inNixShell = if inNixShell then "true" else "false"; inherit stdenv; outputs = ["dev" "out"]; -- cgit v1.2.3 From b1cfe8f984145c836c1dab229c1117d6396a4305 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 8 Jul 2021 17:12:01 +0200 Subject: nix develop: Add a test for arrays --- tests/shell.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/shell.nix') diff --git a/tests/shell.nix b/tests/shell.nix index f174db583..42d2d2033 100644 --- a/tests/shell.nix +++ b/tests/shell.nix @@ -20,6 +20,7 @@ let pkgs = rec { for pkg in $buildInputs; do export PATH=$PATH:$pkg/bin done + declare -a arr1=(1 2 "3 4" 5) ''; stdenv = mkDerivation { -- cgit v1.2.3 From 9fc7da1e08d83378f8b0d66a060d92929c1468cf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 Jul 2021 01:16:55 +0200 Subject: Add test for #4992 --- tests/shell.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/shell.nix') diff --git a/tests/shell.nix b/tests/shell.nix index 42d2d2033..1f5526253 100644 --- a/tests/shell.nix +++ b/tests/shell.nix @@ -21,6 +21,7 @@ let pkgs = rec { export PATH=$PATH:$pkg/bin done declare -a arr1=(1 2 "3 4" 5) + declare -a arr2=(x $'\n' $'x\ny') ''; stdenv = mkDerivation { -- cgit v1.2.3 From e50408bd3192156e04571a1546d053f998ab4e2c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 Jul 2021 01:17:32 +0200 Subject: nix develop: Add a test for bash functions --- tests/shell.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/shell.nix') diff --git a/tests/shell.nix b/tests/shell.nix index 1f5526253..70c60276c 100644 --- a/tests/shell.nix +++ b/tests/shell.nix @@ -22,6 +22,9 @@ let pkgs = rec { done declare -a arr1=(1 2 "3 4" 5) declare -a arr2=(x $'\n' $'x\ny') + fun() { + echo blabla + } ''; stdenv = mkDerivation { -- cgit v1.2.3