Merge branch 'nix-shell-lookup-shell-nix' into more-nix-shell

This commit is contained in:
Robert Hensing 2024-07-07 14:16:15 +02:00
commit 3e424b1040
2 changed files with 9 additions and 5 deletions

View File

@ -116,7 +116,7 @@ $TEST_ROOT/shell.shebang.nix
mkdir $TEST_ROOT/lookup-test $TEST_ROOT/empty mkdir $TEST_ROOT/lookup-test $TEST_ROOT/empty
cp $shellDotNix $TEST_ROOT/lookup-test/shell.nix echo "import $shellDotNix" > $TEST_ROOT/lookup-test/shell.nix
cp config.nix $TEST_ROOT/lookup-test/ cp config.nix $TEST_ROOT/lookup-test/
echo 'abort "do not load default.nix!"' > $TEST_ROOT/lookup-test/default.nix echo 'abort "do not load default.nix!"' > $TEST_ROOT/lookup-test/default.nix
@ -138,10 +138,10 @@ expectStderr 1 nix-shell $TEST_ROOT/lookup-test -A shellDrv --run 'echo "it work
expectStderr 1 nix-shell -I "testRoot=$TEST_ROOT" '<testRoot/empty>' | expectStderr 1 nix-shell -I "testRoot=$TEST_ROOT" '<testRoot/empty>' |
grepQuiet "error.*neither .*shell\.nix.* nor .*default\.nix.* found in .*/empty" grepQuiet "error.*neither .*shell\.nix.* nor .*default\.nix.* found in .*/empty"
cat >$TEST_ROOT/lookup-test/shebangscript <<"EOF" cat >$TEST_ROOT/lookup-test/shebangscript <<EOF
#!/usr/bin/env nix-shell #!$(type -P env) nix-shell
#!nix-shell -A shellDrv -i bash #!nix-shell -A shellDrv -i bash
[[ $VAR_FROM_NIX == bar ]] [[ \$VAR_FROM_NIX == bar ]]
echo "script works" echo "script works"
EOF EOF
chmod +x $TEST_ROOT/lookup-test/shebangscript chmod +x $TEST_ROOT/lookup-test/shebangscript
@ -152,7 +152,7 @@ $TEST_ROOT/lookup-test/shebangscript | grepQuiet "script works"
mkdir $TEST_ROOT/marco{,/polo} mkdir $TEST_ROOT/marco{,/polo}
echo 'abort "marco/shell.nix must not be used, but its mere existence used to cause #5431"' > $TEST_ROOT/marco/shell.nix echo 'abort "marco/shell.nix must not be used, but its mere existence used to cause #5431"' > $TEST_ROOT/marco/shell.nix
cat >$TEST_ROOT/marco/polo/default.nix <<EOF cat >$TEST_ROOT/marco/polo/default.nix <<EOF
#!/usr/bin/env nix-shell #!$(type -P env) nix-shell
(import $TEST_ROOT/lookup-test/shell.nix {}).polo (import $TEST_ROOT/lookup-test/shell.nix {}).polo
EOF EOF
chmod a+x $TEST_ROOT/marco/polo/default.nix chmod a+x $TEST_ROOT/marco/polo/default.nix

View File

@ -26,6 +26,9 @@ let pkgs = rec {
fun() { fun() {
echo blabla echo blabla
} }
runHook() {
eval "''${!1}"
}
''; '';
stdenv = mkDerivation { stdenv = mkDerivation {
@ -54,6 +57,7 @@ let pkgs = rec {
# See nix-shell.sh # See nix-shell.sh
polo = mkDerivation { polo = mkDerivation {
name = "polo"; name = "polo";
inherit stdenv;
shellHook = '' shellHook = ''
echo Polo echo Polo
''; '';