mirror of
https://github.com/NixOS/nix
synced 2025-07-07 14:21:48 +02:00
Merge branch 'master' into structured-attrs-shell
Conflicts: src/nix/develop.cc src/nix/get-env.sh tests/shell.nix
This commit is contained in:
commit
04cd2da84c
104 changed files with 1644 additions and 539 deletions
|
@ -9,7 +9,7 @@ echo $path2
|
|||
if test "$path1" != "$path2"; then
|
||||
echo "nix-store --add and --add-fixed mismatch"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
path3=$(nix-store --add-fixed sha256 ./dummy)
|
||||
echo $path3
|
||||
|
|
|
@ -4,4 +4,6 @@ file=build-hook-ca-floating.nix
|
|||
|
||||
sed -i 's/experimental-features .*/& ca-derivations/' "$NIX_CONF_DIR"/nix.conf
|
||||
|
||||
CONTENT_ADDRESSED=true
|
||||
|
||||
source build-remote.sh
|
||||
|
|
|
@ -6,12 +6,17 @@ unset NIX_STATE_DIR
|
|||
|
||||
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
||||
|
||||
EXTRA_SYSTEM_FEATURES=()
|
||||
if [[ -n "$CONTENT_ADDRESSED" ]]; then
|
||||
EXTRA_SYSTEM_FEATURES=("ca-derivations")
|
||||
fi
|
||||
|
||||
builders=(
|
||||
# system-features will automatically be added to the outer URL, but not inner
|
||||
# remote-store URL.
|
||||
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=foo - - 1 1 foo"
|
||||
"$TEST_ROOT/machine2 - - 1 1 bar"
|
||||
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=baz - - 1 1 baz"
|
||||
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=$(join_by "%20" foo ${EXTRA_SYSTEM_FEATURES[@]}) - - 1 1 $(join_by "," foo ${EXTRA_SYSTEM_FEATURES[@]})"
|
||||
"$TEST_ROOT/machine2 - - 1 1 $(join_by "," bar ${EXTRA_SYSTEM_FEATURES[@]})"
|
||||
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=$(join_by "%20" baz ${EXTRA_SYSTEM_FEATURES[@]}) - - 1 1 $(join_by "," baz ${EXTRA_SYSTEM_FEATURES[@]})"
|
||||
)
|
||||
|
||||
chmod -R +w $TEST_ROOT/machine* || true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
source common.sh
|
||||
|
||||
expectedJSONRegex='\[\{"drvPath":".*multiple-outputs-a.drv","outputs":\{"first":".*multiple-outputs-a-first","second":".*multiple-outputs-a-second"}},\{"drvPath":".*multiple-outputs-b.drv","outputs":\{"out":".*multiple-outputs-b"}}]'
|
||||
nix build -f multiple-outputs.nix --json a.all b.all | jq --exit-status '
|
||||
nix build -f multiple-outputs.nix --json a.all b.all --no-link | jq --exit-status '
|
||||
(.[0] |
|
||||
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
||||
(.outputs.first | match(".*multiple-outputs-a-first")) and
|
||||
|
@ -10,10 +10,10 @@ nix build -f multiple-outputs.nix --json a.all b.all | jq --exit-status '
|
|||
(.drvPath | match(".*multiple-outputs-b.drv")) and
|
||||
(.outputs.out | match(".*multiple-outputs-b")))
|
||||
'
|
||||
|
||||
testNormalization () {
|
||||
clearStore
|
||||
outPath=$(nix-build ./simple.nix)
|
||||
outPath=$(nix-build ./simple.nix --no-out-link)
|
||||
test "$(stat -c %Y $outPath)" -eq 1
|
||||
}
|
||||
|
||||
testNormalization
|
||||
|
|
26
tests/ca/duplicate-realisation-in-closure.sh
Normal file
26
tests/ca/duplicate-realisation-in-closure.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
source ./common.sh
|
||||
|
||||
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
|
||||
|
||||
export REMOTE_STORE_DIR="$TEST_ROOT/remote_store"
|
||||
export REMOTE_STORE="file://$REMOTE_STORE_DIR"
|
||||
|
||||
rm -rf $REMOTE_STORE_DIR
|
||||
clearStore
|
||||
|
||||
# Build dep1 and push that to the binary cache.
|
||||
# This entails building (and pushing) current-time.
|
||||
nix copy --to "$REMOTE_STORE" -f nondeterministic.nix dep1
|
||||
clearStore
|
||||
sleep 2 # To make sure that `$(date)` will be different
|
||||
# Build dep2.
|
||||
# As we’ve cleared the cache, we’ll have to rebuild current-time. And because
|
||||
# the current time isn’t the same as before, this will yield a new (different)
|
||||
# realisation
|
||||
nix build -f nondeterministic.nix dep2 --no-link
|
||||
|
||||
# Build something that depends both on dep1 and dep2.
|
||||
# If everything goes right, we should rebuild dep2 rather than fetch it from
|
||||
# the cache (because that would mean duplicating `current-time` in the closure),
|
||||
# and have `dep1 == dep2`.
|
||||
nix build --substituters "$REMOTE_STORE" -f nondeterministic.nix toplevel --no-require-sigs --no-link
|
12
tests/ca/gc.sh
Executable file
12
tests/ca/gc.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Ensure that garbage collection works properly with ca derivations
|
||||
|
||||
source common.sh
|
||||
|
||||
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
|
||||
cd ..
|
||||
source gc.sh
|
10
tests/ca/nix-shell.sh
Executable file
10
tests/ca/nix-shell.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||
|
||||
CONTENT_ADDRESSED=true
|
||||
cd ..
|
||||
source ./nix-shell.sh
|
||||
|
35
tests/ca/nondeterministic.nix
Normal file
35
tests/ca/nondeterministic.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
with import ./config.nix;
|
||||
|
||||
let mkCADerivation = args: mkDerivation ({
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
} // args);
|
||||
in
|
||||
|
||||
rec {
|
||||
currentTime = mkCADerivation {
|
||||
name = "current-time";
|
||||
buildCommand = ''
|
||||
mkdir $out
|
||||
echo $(date) > $out/current-time
|
||||
'';
|
||||
};
|
||||
dep = seed: mkCADerivation {
|
||||
name = "dep";
|
||||
inherit seed;
|
||||
buildCommand = ''
|
||||
echo ${currentTime} > $out
|
||||
'';
|
||||
};
|
||||
dep1 = dep 1;
|
||||
dep2 = dep 2;
|
||||
toplevel = mkCADerivation {
|
||||
name = "toplevel";
|
||||
buildCommand = ''
|
||||
test ${dep1} == ${dep2}
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
11
tests/ca/post-hook.sh
Executable file
11
tests/ca/post-hook.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
cd ..
|
||||
source ./post-hook.sh
|
||||
|
||||
|
11
tests/ca/recursive.sh
Executable file
11
tests/ca/recursive.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
cd ..
|
||||
source ./recursive.sh
|
||||
|
||||
|
|
@ -17,11 +17,15 @@ buildDrvs () {
|
|||
|
||||
# Populate the remote cache
|
||||
clearStore
|
||||
buildDrvs --post-build-hook ../push-to-store.sh
|
||||
nix copy --to $REMOTE_STORE --file ./content-addressed.nix
|
||||
|
||||
# Restart the build on an empty store, ensuring that we don't build
|
||||
clearStore
|
||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0
|
||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0 transitivelyDependentCA
|
||||
# Check that the thing we’ve just substituted has its realisation stored
|
||||
nix realisation info --file ./content-addressed.nix transitivelyDependentCA
|
||||
# Check that its dependencies have it too
|
||||
nix realisation info --file ./content-addressed.nix dependentCA rootCA
|
||||
|
||||
# Same thing, but
|
||||
# 1. With non-ca derivations
|
||||
|
|
|
@ -44,7 +44,7 @@ with import ./config.nix;
|
|||
};
|
||||
|
||||
hashmismatch = import <nix/fetchurl.nix> {
|
||||
url = "file://" + toString ./dummy;
|
||||
url = "file://" + builtins.getEnv "TMPDIR" + "/dummy";
|
||||
sha256 = "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73";
|
||||
};
|
||||
|
||||
|
|
|
@ -74,12 +74,13 @@ nix-build check.nix -A fetchurl --no-out-link --check
|
|||
nix-build check.nix -A fetchurl --no-out-link --repair
|
||||
[[ $(cat $path) != foo ]]
|
||||
|
||||
echo 'Hello World' > $TMPDIR/dummy
|
||||
nix-build check.nix -A hashmismatch --no-out-link || status=$?
|
||||
[ "$status" = "102" ]
|
||||
|
||||
echo -n > ./dummy
|
||||
echo -n > $TMPDIR/dummy
|
||||
nix-build check.nix -A hashmismatch --no-out-link
|
||||
echo 'Hello World' > ./dummy
|
||||
echo 'Hello World' > $TMPDIR/dummy
|
||||
|
||||
nix-build check.nix -A hashmismatch --no-out-link --check || status=$?
|
||||
[ "$status" = "102" ]
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
let
|
||||
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1";
|
||||
caArgs = if contentAddressedByDefault then {
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
} else {};
|
||||
in
|
||||
|
||||
rec {
|
||||
shell = "@bash@";
|
||||
|
||||
|
@ -13,6 +22,6 @@ rec {
|
|||
builder = shell;
|
||||
args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
|
||||
PATH = path;
|
||||
} // removeAttrs args ["builder" "meta"])
|
||||
} // caArgs // removeAttrs args ["builder" "meta"])
|
||||
// { meta = args.meta or {}; };
|
||||
}
|
||||
|
|
1
tests/dummy
Normal file
1
tests/dummy
Normal file
|
@ -0,0 +1 @@
|
|||
Hello World
|
|
@ -189,3 +189,7 @@ path8=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$rep
|
|||
rev4=$(git -C $repo rev-parse HEAD)
|
||||
rev4_nix=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; ref = \"HEAD\"; }).rev")
|
||||
[[ $rev4 = $rev4_nix ]]
|
||||
|
||||
# The name argument should be handled
|
||||
path9=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repo\"; ref = \"HEAD\"; name = \"foo\"; }).outPath")
|
||||
[[ $path9 =~ -foo$ ]]
|
||||
|
|
|
@ -94,3 +94,8 @@ hg commit --cwd $repo -m 'Bla3'
|
|||
|
||||
path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchMercurial file://$repo).outPath")
|
||||
[[ $path2 = $path4 ]]
|
||||
|
||||
echo paris > $repo/hello
|
||||
# Passing a `name` argument should be reflected in the output path
|
||||
path5=$(nix eval -vvvvv --impure --refresh --raw --expr "(builtins.fetchMercurial { url = \"file://$repo\"; name = \"foo\"; } ).outPath")
|
||||
[[ $path5 =~ -foo$ ]]
|
||||
|
|
|
@ -90,76 +90,14 @@ EOF
|
|||
git -C $nonFlakeDir add README.md
|
||||
git -C $nonFlakeDir commit -m 'Initial'
|
||||
|
||||
cat > $registry <<EOF
|
||||
{
|
||||
"version": 2,
|
||||
"flakes": [
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "flake1"
|
||||
},
|
||||
"to": {
|
||||
"type": "git",
|
||||
"url": "file://$flake1Dir"
|
||||
}
|
||||
},
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "flake2"
|
||||
},
|
||||
"to": {
|
||||
"type": "git",
|
||||
"url": "file://$flake2Dir"
|
||||
}
|
||||
},
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "flake3"
|
||||
},
|
||||
"to": {
|
||||
"type": "git",
|
||||
"url": "file://$flake3Dir"
|
||||
}
|
||||
},
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "flake4"
|
||||
},
|
||||
"to": {
|
||||
"type": "indirect",
|
||||
"id": "flake3"
|
||||
}
|
||||
},
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "flake5"
|
||||
},
|
||||
"to": {
|
||||
"type": "hg",
|
||||
"url": "file://$flake5Dir"
|
||||
}
|
||||
},
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "nixpkgs"
|
||||
},
|
||||
"to": {
|
||||
"type": "indirect",
|
||||
"id": "flake1"
|
||||
}
|
||||
},
|
||||
{ "from": {
|
||||
"type": "indirect",
|
||||
"id": "templates"
|
||||
},
|
||||
"to": {
|
||||
"type": "git",
|
||||
"url": "file://$templatesDir"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
# Construct a custom registry, additionally test the --registry flag
|
||||
nix registry add --registry $registry flake1 git+file://$flake1Dir
|
||||
nix registry add --registry $registry flake2 git+file://$flake2Dir
|
||||
nix registry add --registry $registry flake3 git+file://$flake3Dir
|
||||
nix registry add --registry $registry flake4 flake3
|
||||
nix registry add --registry $registry flake5 hg+file://$flake5Dir
|
||||
nix registry add --registry $registry nixpkgs flake1
|
||||
nix registry add --registry $registry templates git+file://$templatesDir
|
||||
|
||||
# Test 'nix flake list'.
|
||||
[[ $(nix registry list | wc -l) == 7 ]]
|
||||
|
@ -405,6 +343,8 @@ nix registry add flake1 flake3
|
|||
[[ $(nix registry list | wc -l) == 8 ]]
|
||||
nix registry pin flake1
|
||||
[[ $(nix registry list | wc -l) == 8 ]]
|
||||
nix registry pin flake1 flake3
|
||||
[[ $(nix registry list | wc -l) == 8 ]]
|
||||
nix registry remove flake1
|
||||
[[ $(nix registry list | wc -l) == 7 ]]
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
|
|||
nix-store --gc --print-roots | grep $outPath
|
||||
nix-store --gc --print-live | grep $outPath
|
||||
nix-store --gc --print-dead | grep $drvPath
|
||||
if nix-store --gc --print-dead | grep $outPath; then false; fi
|
||||
if nix-store --gc --print-dead | grep -E $outPath$; then false; fi
|
||||
|
||||
nix-store --gc --print-dead
|
||||
|
||||
|
|
|
@ -35,5 +35,3 @@ nix-store --init
|
|||
|
||||
# Did anything happen?
|
||||
test -e "$NIX_STATE_DIR"/db/db.sqlite
|
||||
|
||||
echo 'Hello World' > ./dummy
|
||||
|
|
|
@ -2,6 +2,7 @@ nix_tests = \
|
|||
hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
||||
config.sh \
|
||||
gc.sh \
|
||||
ca/gc.sh \
|
||||
gc-concurrent.sh \
|
||||
gc-auto.sh \
|
||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||
|
@ -38,6 +39,7 @@ nix_tests = \
|
|||
search.sh \
|
||||
nix-copy-ssh.sh \
|
||||
post-hook.sh \
|
||||
ca/post-hook.sh \
|
||||
function-trace.sh \
|
||||
recursive.sh \
|
||||
describe-stores.sh \
|
||||
|
@ -46,9 +48,12 @@ nix_tests = \
|
|||
compute-levels.sh \
|
||||
ca/build.sh \
|
||||
ca/build-with-garbage-path.sh \
|
||||
ca/duplicate-realisation-in-closure.sh \
|
||||
ca/substitute.sh \
|
||||
ca/signatures.sh \
|
||||
ca/nix-shell.sh \
|
||||
ca/nix-run.sh \
|
||||
ca/recursive.sh \
|
||||
ca/nix-copy.sh
|
||||
# parallel.sh
|
||||
|
||||
|
|
|
@ -2,6 +2,20 @@ source common.sh
|
|||
|
||||
clearStore
|
||||
|
||||
if [[ -n ${CONTENT_ADDRESSED:-} ]]; then
|
||||
nix-shell () {
|
||||
command nix-shell --arg contentAddressed true "$@"
|
||||
}
|
||||
|
||||
nix_develop() {
|
||||
nix develop --arg contentAddressed true "$@"
|
||||
}
|
||||
else
|
||||
nix_develop() {
|
||||
nix develop "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# Test nix-shell -A
|
||||
export IMPURE_VAR=foo
|
||||
export SELECTED_IMPURE_VAR=baz
|
||||
|
@ -41,7 +55,7 @@ output=$(NIX_PATH=nixpkgs=shell.nix nix-shell --pure -p foo bar --run 'echo "$(f
|
|||
[ "$output" = "foo bar" ]
|
||||
|
||||
# Test nix-shell shebang mode
|
||||
sed -e "s|@ENV_PROG@|$(type -p env)|" shell.shebang.sh > $TEST_ROOT/shell.shebang.sh
|
||||
sed -e "s|@ENV_PROG@|$(type -P env)|" shell.shebang.sh > $TEST_ROOT/shell.shebang.sh
|
||||
chmod a+rx $TEST_ROOT/shell.shebang.sh
|
||||
|
||||
output=$($TEST_ROOT/shell.shebang.sh abc def)
|
||||
|
@ -49,7 +63,7 @@ output=$($TEST_ROOT/shell.shebang.sh abc def)
|
|||
|
||||
# Test nix-shell shebang mode again with metacharacters in the filename.
|
||||
# First word of filename is chosen to not match any file in the test root.
|
||||
sed -e "s|@ENV_PROG@|$(type -p env)|" shell.shebang.sh > $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
||||
sed -e "s|@ENV_PROG@|$(type -P env)|" shell.shebang.sh > $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
||||
chmod a+rx $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
||||
|
||||
output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.sh abc def)
|
||||
|
@ -58,7 +72,7 @@ output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.sh abc def)
|
|||
# Test nix-shell shebang mode for ruby
|
||||
# This uses a fake interpreter that returns the arguments passed
|
||||
# This, in turn, verifies the `rc` script is valid and the `load()` script (given using `-e`) is as expected.
|
||||
sed -e "s|@SHELL_PROG@|$(type -p nix-shell)|" shell.shebang.rb > $TEST_ROOT/shell.shebang.rb
|
||||
sed -e "s|@SHELL_PROG@|$(type -P nix-shell)|" shell.shebang.rb > $TEST_ROOT/shell.shebang.rb
|
||||
chmod a+rx $TEST_ROOT/shell.shebang.rb
|
||||
|
||||
output=$($TEST_ROOT/shell.shebang.rb abc ruby)
|
||||
|
@ -66,21 +80,27 @@ output=$($TEST_ROOT/shell.shebang.rb abc ruby)
|
|||
|
||||
# Test nix-shell shebang mode for ruby again with metacharacters in the filename.
|
||||
# Note: fake interpreter only space-separates args without adding escapes to its output.
|
||||
sed -e "s|@SHELL_PROG@|$(type -p nix-shell)|" shell.shebang.rb > $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
||||
sed -e "s|@SHELL_PROG@|$(type -P nix-shell)|" shell.shebang.rb > $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
||||
chmod a+rx $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
||||
|
||||
output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.rb abc ruby)
|
||||
[ "$output" = '-e load(ARGV.shift) -- '"$TEST_ROOT"'/spaced \'\''"shell.shebang.rb abc ruby' ]
|
||||
|
||||
# Test 'nix develop'.
|
||||
nix develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
|
||||
nix_develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
|
||||
|
||||
# Ensure `nix develop -c` preserves stdin
|
||||
echo foo | nix develop -f shell.nix shellDrv -c cat | grep -q foo
|
||||
|
||||
# Ensure `nix develop -c` actually executes the command if stdout isn't a terminal
|
||||
nix develop -f shell.nix shellDrv -c echo foo |& grep -q foo
|
||||
nix_develop -f shell.nix shellDrv -c echo foo |& grep -q foo
|
||||
|
||||
# Test 'nix print-dev-env'.
|
||||
[[ $(nix print-dev-env -f shell.nix shellDrv --json | jq -r .variables.arr1.value[2]) = '3 4' ]]
|
||||
|
||||
source <(nix print-dev-env -f shell.nix shellDrv)
|
||||
[[ -n $stdenv ]]
|
||||
[[ ${arr1[2]} = "3 4" ]]
|
||||
[[ ${arr2[1]} = $'\n' ]]
|
||||
[[ ${arr2[2]} = $'x\ny' ]]
|
||||
[[ $(fun) = blabla ]]
|
||||
|
|
|
@ -4,7 +4,7 @@ clearStore
|
|||
|
||||
rm -f $TEST_ROOT/result
|
||||
|
||||
export REMOTE_STORE=$TEST_ROOT/remote_store
|
||||
export REMOTE_STORE=file:$TEST_ROOT/remote_store
|
||||
|
||||
# Build the dependencies and push them to the remote store
|
||||
nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook $PWD/push-to-store.sh
|
||||
|
|
|
@ -9,9 +9,9 @@ rm -f $TEST_ROOT/result
|
|||
|
||||
export unreachable=$(nix store add-path ./recursive.sh)
|
||||
|
||||
NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command recursive-nix' build -o $TEST_ROOT/result -L --impure --expr '
|
||||
NIX_BIN_DIR=$(dirname $(type -p nix)) nix --extra-experimental-features 'nix-command recursive-nix' build -o $TEST_ROOT/result -L --impure --expr '
|
||||
with import ./config.nix;
|
||||
mkDerivation {
|
||||
mkDerivation rec {
|
||||
name = "recursive";
|
||||
dummy = builtins.toFile "dummy" "bla bla";
|
||||
SHELL = shell;
|
||||
|
@ -19,11 +19,13 @@ NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command r
|
|||
# Note: this is a string without context.
|
||||
unreachable = builtins.getEnv "unreachable";
|
||||
|
||||
NIX_TESTS_CA_BY_DEFAULT = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT";
|
||||
|
||||
requiredSystemFeatures = [ "recursive-nix" ];
|
||||
|
||||
buildCommand = '\'\''
|
||||
mkdir $out
|
||||
opts="--experimental-features nix-command"
|
||||
opts="--experimental-features nix-command ${if (NIX_TESTS_CA_BY_DEFAULT == "1") then "--extra-experimental-features ca-derivations" else ""}"
|
||||
|
||||
PATH=${builtins.getEnv "NIX_BIN_DIR"}:$PATH
|
||||
|
||||
|
@ -46,16 +48,15 @@ NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command r
|
|||
# Add it to our closure.
|
||||
ln -s $foobar $out/foobar
|
||||
|
||||
[[ $(nix $opts path-info --all | wc -l) -eq 3 ]]
|
||||
[[ $(nix $opts path-info --all | wc -l) -eq 4 ]]
|
||||
|
||||
# Build a derivation.
|
||||
nix $opts build -L --impure --expr '\''
|
||||
derivation {
|
||||
with import ${./config.nix};
|
||||
mkDerivation {
|
||||
name = "inner1";
|
||||
builder = builtins.getEnv "SHELL";
|
||||
system = builtins.getEnv "system";
|
||||
buildCommand = "echo $fnord blaat > $out";
|
||||
fnord = builtins.toFile "fnord" "fnord";
|
||||
args = [ "-c" "echo $fnord blaat > $out" ];
|
||||
}
|
||||
'\''
|
||||
|
||||
|
|
|
@ -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" ''
|
||||
|
@ -16,6 +28,12 @@ let pkgs = rec {
|
|||
export "''${o}"
|
||||
done
|
||||
fi
|
||||
|
||||
declare -a arr1=(1 2 "3 4" 5)
|
||||
declare -a arr2=(x $'\n' $'x\ny')
|
||||
fun() {
|
||||
echo blabla
|
||||
}
|
||||
'';
|
||||
|
||||
stdenv = mkDerivation {
|
||||
|
@ -30,6 +48,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"];
|
||||
|
|
|
@ -40,6 +40,11 @@ test_tarball() {
|
|||
(! nix-instantiate --eval -E '<fnord/xyzzy> 1' -I fnord=file://no-such-tarball$ext)
|
||||
|
||||
nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file://no-such-tarball$ext -I fnord=.
|
||||
|
||||
# Ensure that the `name` attribute isn’t accepted as that would mess
|
||||
# with the content-addressing
|
||||
(! nix-instantiate --eval -E "fetchTree { type = \"tarball\"; url = file://$tarball; narHash = \"$hash\"; name = \"foo\"; }")
|
||||
|
||||
}
|
||||
|
||||
test_tarball '' cat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue