Add 'third_party/nix/' from commit 'be66c7a6b24e3c3c6157fd37b86c7203d14acf10'
git-subtree-dir: third_party/nix
git-subtree-mainline: cf8cd640c1
git-subtree-split: be66c7a6b24e3c3c6157fd37b86c7203d14acf10
This commit is contained in:
commit
7994fd1d54
737 changed files with 105390 additions and 0 deletions
28
third_party/nix/tests/add.sh
vendored
Normal file
28
third_party/nix/tests/add.sh
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
source common.sh
|
||||
|
||||
path1=$(nix-store --add ./dummy)
|
||||
echo $path1
|
||||
|
||||
path2=$(nix-store --add-fixed sha256 --recursive ./dummy)
|
||||
echo $path2
|
||||
|
||||
if test "$path1" != "$path2"; then
|
||||
echo "nix-store --add and --add-fixed mismatch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
path3=$(nix-store --add-fixed sha256 ./dummy)
|
||||
echo $path3
|
||||
test "$path1" != "$path3" || exit 1
|
||||
|
||||
path4=$(nix-store --add-fixed sha1 --recursive ./dummy)
|
||||
echo $path4
|
||||
test "$path1" != "$path4" || exit 1
|
||||
|
||||
hash1=$(nix-store -q --hash $path1)
|
||||
echo $hash1
|
||||
|
||||
hash2=$(nix-hash --type sha256 --base32 ./dummy)
|
||||
echo $hash2
|
||||
|
||||
test "$hash1" = "sha256:$hash2"
|
||||
170
third_party/nix/tests/binary-cache.sh
vendored
Normal file
170
third_party/nix/tests/binary-cache.sh
vendored
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
# Create the binary cache.
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
nix copy --to file://$cacheDir $outPath
|
||||
|
||||
|
||||
basicTests() {
|
||||
|
||||
# By default, a binary cache doesn't support "nix-env -qas", but does
|
||||
# support installation.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
nix-env --substituters "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "---"
|
||||
|
||||
nix-store --substituters "file://$cacheDir" --no-require-sigs -r $outPath
|
||||
|
||||
[ -x $outPath/program ]
|
||||
|
||||
|
||||
# But with the right configuration, "nix-env -qas" should also work.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
echo "WantMassQuery: 1" >> $cacheDir/nix-cache-info
|
||||
|
||||
nix-env --substituters "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "--S"
|
||||
nix-env --substituters "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "--S"
|
||||
|
||||
x=$(nix-env -f dependencies.nix -qas \* --prebuilt-only)
|
||||
[ -z "$x" ]
|
||||
|
||||
nix-store --substituters "file://$cacheDir" --no-require-sigs -r $outPath
|
||||
|
||||
nix-store --check-validity $outPath
|
||||
nix-store -qR $outPath | grep input-2
|
||||
|
||||
echo "WantMassQuery: 0" >> $cacheDir/nix-cache-info
|
||||
}
|
||||
|
||||
|
||||
# Test LocalBinaryCacheStore.
|
||||
basicTests
|
||||
|
||||
|
||||
# Test HttpBinaryCacheStore.
|
||||
export _NIX_FORCE_HTTP_BINARY_CACHE_STORE=1
|
||||
basicTests
|
||||
|
||||
|
||||
# Test whether Nix notices if the NAR doesn't match the hash in the NAR info.
|
||||
clearStore
|
||||
|
||||
nar=$(ls $cacheDir/nar/*.nar.xz | head -n1)
|
||||
mv $nar $nar.good
|
||||
mkdir -p $TEST_ROOT/empty
|
||||
nix-store --dump $TEST_ROOT/empty | xz > $nar
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||
grep -q "hash mismatch" $TEST_ROOT/log
|
||||
|
||||
mv $nar.good $nar
|
||||
|
||||
|
||||
# Test whether this unsigned cache is rejected if the user requires signed caches.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
if nix-store --substituters "file://$cacheDir" -r $outPath; then
|
||||
echo "unsigned binary cache incorrectly accepted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Test whether fallback works if a NAR has disappeared. This does not require --fallback.
|
||||
clearStore
|
||||
|
||||
mv $cacheDir/nar $cacheDir/nar2
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result
|
||||
|
||||
mv $cacheDir/nar2 $cacheDir/nar
|
||||
|
||||
|
||||
# Test whether fallback works if a NAR is corrupted. This does require --fallback.
|
||||
clearStore
|
||||
|
||||
mv $cacheDir/nar $cacheDir/nar2
|
||||
mkdir $cacheDir/nar
|
||||
for i in $(cd $cacheDir/nar2 && echo *); do touch $cacheDir/nar/$i; done
|
||||
|
||||
(! nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result)
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result --fallback
|
||||
|
||||
rm -rf $cacheDir/nar
|
||||
mv $cacheDir/nar2 $cacheDir/nar
|
||||
|
||||
|
||||
# Test whether building works if the binary cache contains an
|
||||
# incomplete closure.
|
||||
clearStore
|
||||
|
||||
rm $(grep -l "StorePath:.*dependencies-input-2" $cacheDir/*.narinfo)
|
||||
|
||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||
grep -q "copying path" $TEST_ROOT/log
|
||||
|
||||
|
||||
if [ -n "$HAVE_SODIUM" ]; then
|
||||
|
||||
# Create a signed binary cache.
|
||||
clearCache
|
||||
clearCacheCache
|
||||
|
||||
declare -a res=($(nix-store --generate-binary-cache-key test.nixos.org-1 $TEST_ROOT/sk1 $TEST_ROOT/pk1 ))
|
||||
publicKey="$(cat $TEST_ROOT/pk1)"
|
||||
|
||||
res=($(nix-store --generate-binary-cache-key test.nixos.org-1 $TEST_ROOT/sk2 $TEST_ROOT/pk2))
|
||||
badKey="$(cat $TEST_ROOT/pk2)"
|
||||
|
||||
res=($(nix-store --generate-binary-cache-key foo.nixos.org-1 $TEST_ROOT/sk3 $TEST_ROOT/pk3))
|
||||
otherKey="$(cat $TEST_ROOT/pk3)"
|
||||
|
||||
_NIX_FORCE_HTTP_BINARY_CACHE_STORE= nix copy --to file://$cacheDir?secret-key=$TEST_ROOT/sk1 $outPath
|
||||
|
||||
|
||||
# Downloading should fail if we don't provide a key.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
(! nix-store -r $outPath --substituters "file://$cacheDir")
|
||||
|
||||
|
||||
# And it should fail if we provide an incorrect key.
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
(! nix-store -r $outPath --substituters "file://$cacheDir" --trusted-public-keys "$badKey")
|
||||
|
||||
|
||||
# It should succeed if we provide the correct key.
|
||||
nix-store -r $outPath --substituters "file://$cacheDir" --trusted-public-keys "$otherKey $publicKey"
|
||||
|
||||
|
||||
# It should fail if we corrupt the .narinfo.
|
||||
clearStore
|
||||
|
||||
cacheDir2=$TEST_ROOT/binary-cache-2
|
||||
rm -rf $cacheDir2
|
||||
cp -r $cacheDir $cacheDir2
|
||||
|
||||
for i in $cacheDir2/*.narinfo; do
|
||||
grep -v References $i > $i.tmp
|
||||
mv $i.tmp $i
|
||||
done
|
||||
|
||||
clearCacheCache
|
||||
|
||||
(! nix-store -r $outPath --substituters "file://$cacheDir2" --trusted-public-keys "$publicKey")
|
||||
|
||||
# If we provide a bad and a good binary cache, it should succeed.
|
||||
|
||||
nix-store -r $outPath --substituters "file://$cacheDir2 file://$cacheDir" --trusted-public-keys "$publicKey"
|
||||
|
||||
fi # HAVE_LIBSODIUM
|
||||
21
third_party/nix/tests/brotli.sh
vendored
Normal file
21
third_party/nix/tests/brotli.sh
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
cacheURI="file://$cacheDir?compression=br"
|
||||
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
nix copy --to $cacheURI $outPath
|
||||
|
||||
HASH=$(nix hash-path $outPath)
|
||||
|
||||
clearStore
|
||||
clearCacheCache
|
||||
|
||||
nix copy --from $cacheURI $outPath --no-check-sigs
|
||||
|
||||
HASH2=$(nix hash-path $outPath)
|
||||
|
||||
[[ $HASH = $HASH2 ]]
|
||||
52
third_party/nix/tests/build-dry.sh
vendored
Normal file
52
third_party/nix/tests/build-dry.sh
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
source common.sh
|
||||
|
||||
###################################################
|
||||
# Check that --dry-run isn't confused with read-only mode
|
||||
# https://github.com/NixOS/nix/issues/1795
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
# Ensure this builds successfully first
|
||||
nix build --no-link -f dependencies.nix
|
||||
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
# Try --dry-run using old command first
|
||||
nix-build --no-out-link dependencies.nix --dry-run 2>&1 | grep "will be built"
|
||||
# Now new command:
|
||||
nix build -f dependencies.nix --dry-run 2>&1 | grep "will be built"
|
||||
|
||||
# TODO: XXX: FIXME: #1793
|
||||
# Disable this part of the test until the problem is resolved:
|
||||
if [ -n "$ISSUE_1795_IS_FIXED" ]; then
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
# Try --dry-run using new command first
|
||||
nix build -f dependencies.nix --dry-run 2>&1 | grep "will be built"
|
||||
# Now old command:
|
||||
nix-build --no-out-link dependencies.nix --dry-run 2>&1 | grep "will be built"
|
||||
fi
|
||||
|
||||
###################################################
|
||||
# Check --dry-run doesn't create links with --dry-run
|
||||
# https://github.com/NixOS/nix/issues/1849
|
||||
clearStore
|
||||
clearCache
|
||||
|
||||
RESULT=$TEST_ROOT/result-link
|
||||
rm -f $RESULT
|
||||
|
||||
nix-build dependencies.nix -o $RESULT --dry-run
|
||||
|
||||
[[ ! -h $RESULT ]] || fail "nix-build --dry-run created output link"
|
||||
|
||||
nix build -f dependencies.nix -o $RESULT --dry-run
|
||||
|
||||
[[ ! -h $RESULT ]] || fail "nix build --dry-run created output link"
|
||||
|
||||
nix build -f dependencies.nix -o $RESULT
|
||||
|
||||
[[ -h $RESULT ]]
|
||||
23
third_party/nix/tests/build-hook.nix
vendored
Normal file
23
third_party/nix/tests/build-hook.nix
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
input1 = mkDerivation {
|
||||
name = "build-hook-input-1";
|
||||
builder = ./dependencies.builder1.sh;
|
||||
requiredSystemFeatures = ["foo"];
|
||||
};
|
||||
|
||||
input2 = mkDerivation {
|
||||
name = "build-hook-input-2";
|
||||
builder = ./dependencies.builder2.sh;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
mkDerivation {
|
||||
name = "build-hook";
|
||||
builder = ./dependencies.builder0.sh;
|
||||
input1 = " " + input1 + "/.";
|
||||
input2 = " ${input2}/.";
|
||||
}
|
||||
24
third_party/nix/tests/build-remote.sh
vendored
Normal file
24
third_party/nix/tests/build-remote.sh
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
if ! canUseSandbox; then exit; fi
|
||||
if [[ ! $SHELL =~ /nix/store ]]; then exit; fi
|
||||
|
||||
chmod -R u+w $TEST_ROOT/store0 || true
|
||||
chmod -R u+w $TEST_ROOT/store1 || true
|
||||
rm -rf $TEST_ROOT/store0 $TEST_ROOT/store1
|
||||
|
||||
nix build -f build-hook.nix -o $TEST_ROOT/result --max-jobs 0 \
|
||||
--sandbox-paths /nix/store --sandbox-build-dir /build-tmp \
|
||||
--builders "$TEST_ROOT/store0; $TEST_ROOT/store1 - - 1 1 foo" \
|
||||
--system-features foo
|
||||
|
||||
outPath=$TEST_ROOT/result
|
||||
|
||||
cat $outPath/foobar | grep FOOBAR
|
||||
|
||||
# Ensure that input1 was built on store1 due to the required feature.
|
||||
p=$(readlink -f $outPath/input-2)
|
||||
(! nix path-info --store $TEST_ROOT/store0 --all | grep dependencies.builder1.sh)
|
||||
nix path-info --store $TEST_ROOT/store1 --all | grep dependencies.builder1.sh
|
||||
19
third_party/nix/tests/case-hack.sh
vendored
Normal file
19
third_party/nix/tests/case-hack.sh
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
rm -rf $TEST_ROOT/case
|
||||
|
||||
opts="--option use-case-hack true"
|
||||
|
||||
# Check whether restoring and dumping a NAR that contains case
|
||||
# collisions is round-tripping, even on a case-insensitive system.
|
||||
nix-store $opts --restore $TEST_ROOT/case < case.nar
|
||||
nix-store $opts --dump $TEST_ROOT/case > $TEST_ROOT/case.nar
|
||||
cmp case.nar $TEST_ROOT/case.nar
|
||||
[ "$(nix-hash $opts --type sha256 $TEST_ROOT/case)" = "$(nix-hash --flat --type sha256 case.nar)" ]
|
||||
|
||||
# Check whether we detect true collisions (e.g. those remaining after
|
||||
# removal of the suffix).
|
||||
touch "$TEST_ROOT/case/xt_CONNMARK.h~nix~case~hack~3"
|
||||
(! nix-store $opts --dump $TEST_ROOT/case > /dev/null)
|
||||
BIN
third_party/nix/tests/case.nar
vendored
Normal file
BIN
third_party/nix/tests/case.nar
vendored
Normal file
Binary file not shown.
70
third_party/nix/tests/check-refs.nix
vendored
Normal file
70
third_party/nix/tests/check-refs.nix
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
dep = import ./dependencies.nix;
|
||||
|
||||
makeTest = nr: args: mkDerivation ({
|
||||
name = "check-refs-" + toString nr;
|
||||
} // args);
|
||||
|
||||
src = builtins.toFile "aux-ref" "bla bla";
|
||||
|
||||
test1 = makeTest 1 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test2 = makeTest 2 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s ${src} $out/link";
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test3 = makeTest 3 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
|
||||
allowedReferences = [];
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test4 = makeTest 4 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
|
||||
allowedReferences = [dep];
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test5 = makeTest 5 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out";
|
||||
allowedReferences = [];
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test6 = makeTest 6 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link";
|
||||
allowedReferences = [];
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test7 = makeTest 7 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $out $out/link";
|
||||
allowedReferences = ["out"];
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test8 = makeTest 8 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s ${test1} $out/link";
|
||||
inherit dep;
|
||||
};
|
||||
|
||||
test9 = makeTest 9 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $dep $out/link";
|
||||
inherit dep;
|
||||
disallowedReferences = [dep];
|
||||
};
|
||||
|
||||
test10 = makeTest 10 {
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; echo $test5; ln -s $dep $out/link";
|
||||
inherit dep test5;
|
||||
disallowedReferences = [test5];
|
||||
};
|
||||
|
||||
}
|
||||
42
third_party/nix/tests/check-refs.sh
vendored
Normal file
42
third_party/nix/tests/check-refs.sh
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
RESULT=$TEST_ROOT/result
|
||||
|
||||
dep=$(nix-build -o $RESULT check-refs.nix -A dep)
|
||||
|
||||
# test1 references dep, not itself.
|
||||
test1=$(nix-build -o $RESULT check-refs.nix -A test1)
|
||||
(! nix-store -q --references $test1 | grep -q $test1)
|
||||
nix-store -q --references $test1 | grep -q $dep
|
||||
|
||||
# test2 references src, not itself nor dep.
|
||||
test2=$(nix-build -o $RESULT check-refs.nix -A test2)
|
||||
(! nix-store -q --references $test2 | grep -q $test2)
|
||||
(! nix-store -q --references $test2 | grep -q $dep)
|
||||
nix-store -q --references $test2 | grep -q aux-ref
|
||||
|
||||
# test3 should fail (unallowed ref).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test3)
|
||||
|
||||
# test4 should succeed.
|
||||
nix-build -o $RESULT check-refs.nix -A test4
|
||||
|
||||
# test5 should succeed.
|
||||
nix-build -o $RESULT check-refs.nix -A test5
|
||||
|
||||
# test6 should fail (unallowed self-ref).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test6)
|
||||
|
||||
# test7 should succeed (allowed self-ref).
|
||||
nix-build -o $RESULT check-refs.nix -A test7
|
||||
|
||||
# test8 should fail (toFile depending on derivation output).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test8)
|
||||
|
||||
# test9 should fail (disallowed reference).
|
||||
(! nix-build -o $RESULT check-refs.nix -A test9)
|
||||
|
||||
# test10 should succeed (no disallowed references).
|
||||
nix-build -o $RESULT check-refs.nix -A test10
|
||||
57
third_party/nix/tests/check-reqs.nix
vendored
Normal file
57
third_party/nix/tests/check-reqs.nix
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
dep1 = mkDerivation {
|
||||
name = "check-reqs-dep1";
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; touch $out/file1";
|
||||
};
|
||||
|
||||
dep2 = mkDerivation {
|
||||
name = "check-reqs-dep2";
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; touch $out/file2";
|
||||
};
|
||||
|
||||
deps = mkDerivation {
|
||||
name = "check-reqs-deps";
|
||||
dep1 = dep1;
|
||||
dep2 = dep2;
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
mkdir $out
|
||||
ln -s $dep1/file1 $out/file1
|
||||
ln -s $dep2/file2 $out/file2
|
||||
'';
|
||||
};
|
||||
|
||||
makeTest = nr: allowreqs: mkDerivation {
|
||||
name = "check-reqs-" + toString nr;
|
||||
inherit deps;
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
mkdir $out
|
||||
ln -s $deps $out/depdir1
|
||||
'';
|
||||
allowedRequisites = allowreqs;
|
||||
};
|
||||
|
||||
# When specifying all the requisites, the build succeeds.
|
||||
test1 = makeTest 1 [ dep1 dep2 deps ];
|
||||
|
||||
# But missing anything it fails.
|
||||
test2 = makeTest 2 [ dep2 deps ];
|
||||
test3 = makeTest 3 [ dep1 deps ];
|
||||
test4 = makeTest 4 [ deps ];
|
||||
test5 = makeTest 5 [];
|
||||
|
||||
test6 = mkDerivation {
|
||||
name = "check-reqs";
|
||||
inherit deps;
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $deps $out/depdir1";
|
||||
disallowedRequisites = [dep1];
|
||||
};
|
||||
|
||||
test7 = mkDerivation {
|
||||
name = "check-reqs";
|
||||
inherit deps;
|
||||
builder = builtins.toFile "builder.sh" "mkdir $out; ln -s $deps $out/depdir1";
|
||||
disallowedRequisites = [test1];
|
||||
};
|
||||
}
|
||||
16
third_party/nix/tests/check-reqs.sh
vendored
Normal file
16
third_party/nix/tests/check-reqs.sh
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
RESULT=$TEST_ROOT/result
|
||||
|
||||
nix-build -o $RESULT check-reqs.nix -A test1
|
||||
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test2)
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test3)
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test4) 2>&1 | grep -q 'check-reqs-dep1'
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test4) 2>&1 | grep -q 'check-reqs-dep2'
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test5)
|
||||
(! nix-build -o $RESULT check-reqs.nix -A test6)
|
||||
|
||||
nix-build -o $RESULT check-reqs.nix -A test7
|
||||
22
third_party/nix/tests/check.nix
vendored
Normal file
22
third_party/nix/tests/check.nix
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
with import ./config.nix;
|
||||
|
||||
{
|
||||
nondeterministic = mkDerivation {
|
||||
name = "nondeterministic";
|
||||
buildCommand =
|
||||
''
|
||||
mkdir $out
|
||||
date +%s.%N > $out/date
|
||||
'';
|
||||
};
|
||||
|
||||
hashmismatch = import <nix/fetchurl.nix> {
|
||||
url = "file://" + toString ./dummy;
|
||||
sha256 = "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73";
|
||||
};
|
||||
|
||||
fetchurl = import <nix/fetchurl.nix> {
|
||||
url = "file://" + toString ./lang/eval-okay-xml.exp.xml;
|
||||
sha256 = "0kg4sla7ihm8ijr8cb3117fhl99zrc2bwy1jrngsfmkh8bav4m0v";
|
||||
};
|
||||
}
|
||||
47
third_party/nix/tests/check.sh
vendored
Normal file
47
third_party/nix/tests/check.sh
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
nix-build dependencies.nix --no-out-link
|
||||
nix-build dependencies.nix --no-out-link --check
|
||||
|
||||
nix-build check.nix -A nondeterministic --no-out-link
|
||||
nix-build check.nix -A nondeterministic --no-out-link --check 2> $TEST_ROOT/log || status=$?
|
||||
grep 'may not be deterministic' $TEST_ROOT/log
|
||||
[ "$status" = "104" ]
|
||||
|
||||
clearStore
|
||||
|
||||
nix-build dependencies.nix --no-out-link --repeat 3
|
||||
|
||||
nix-build check.nix -A nondeterministic --no-out-link --repeat 1 2> $TEST_ROOT/log || status=$?
|
||||
[ "$status" = "1" ]
|
||||
grep 'differs from previous round' $TEST_ROOT/log
|
||||
|
||||
path=$(nix-build check.nix -A fetchurl --no-out-link --hashed-mirrors '')
|
||||
|
||||
chmod +w $path
|
||||
echo foo > $path
|
||||
chmod -w $path
|
||||
|
||||
nix-build check.nix -A fetchurl --no-out-link --check --hashed-mirrors ''
|
||||
# Note: "check" doesn't repair anything, it just compares to the hash stored in the database.
|
||||
[[ $(cat $path) = foo ]]
|
||||
|
||||
nix-build check.nix -A fetchurl --no-out-link --repair --hashed-mirrors ''
|
||||
[[ $(cat $path) != foo ]]
|
||||
|
||||
nix-build check.nix -A hashmismatch --no-out-link --hashed-mirrors '' || status=$?
|
||||
[ "$status" = "102" ]
|
||||
|
||||
echo -n > ./dummy
|
||||
nix-build check.nix -A hashmismatch --no-out-link --hashed-mirrors ''
|
||||
echo 'Hello World' > ./dummy
|
||||
|
||||
nix-build check.nix -A hashmismatch --no-out-link --check --hashed-mirrors '' || status=$?
|
||||
[ "$status" = "102" ]
|
||||
|
||||
# Multiple failures with --keep-going
|
||||
nix-build check.nix -A nondeterministic --no-out-link
|
||||
nix-build check.nix -A nondeterministic -A hashmismatch --no-out-link --check --keep-going --hashed-mirrors '' || status=$?
|
||||
[ "$status" = "110" ]
|
||||
118
third_party/nix/tests/common.sh.in
vendored
Normal file
118
third_party/nix/tests/common.sh.in
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
set -e
|
||||
|
||||
export TEST_ROOT=$(realpath ${TMPDIR:-/tmp}/nix-test)
|
||||
export NIX_STORE_DIR
|
||||
if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then
|
||||
# Maybe the build directory is symlinked.
|
||||
export NIX_IGNORE_SYMLINK_STORE=1
|
||||
NIX_STORE_DIR=$TEST_ROOT/store
|
||||
fi
|
||||
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
||||
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
||||
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
||||
export NIX_CONF_DIR=$TEST_ROOT/etc
|
||||
export _NIX_TEST_SHARED=$TEST_ROOT/shared
|
||||
if [[ -n $NIX_STORE ]]; then
|
||||
export _NIX_TEST_NO_SANDBOX=1
|
||||
fi
|
||||
export _NIX_IN_TEST=$TEST_ROOT/shared
|
||||
export _NIX_TEST_NO_LSOF=1
|
||||
export NIX_REMOTE=$NIX_REMOTE_
|
||||
unset NIX_PATH
|
||||
export TEST_HOME=$TEST_ROOT/test-home
|
||||
export HOME=$TEST_HOME
|
||||
unset XDG_CACHE_HOME
|
||||
mkdir -p $TEST_HOME
|
||||
|
||||
export PATH=@bindir@:$PATH
|
||||
coreutils=@coreutils@
|
||||
|
||||
export dot=@dot@
|
||||
export xmllint="@xmllint@"
|
||||
export SHELL="@bash@"
|
||||
export PAGER=cat
|
||||
export HAVE_SODIUM="@HAVE_SODIUM@"
|
||||
|
||||
export version=@PACKAGE_VERSION@
|
||||
export system=@system@
|
||||
|
||||
cacheDir=$TEST_ROOT/binary-cache
|
||||
|
||||
readLink() {
|
||||
ls -l "$1" | sed 's/.*->\ //'
|
||||
}
|
||||
|
||||
clearProfiles() {
|
||||
profiles="$NIX_STATE_DIR"/profiles
|
||||
rm -rf $profiles
|
||||
}
|
||||
|
||||
clearStore() {
|
||||
echo "clearing store..."
|
||||
chmod -R +w "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_STORE_DIR"
|
||||
mkdir "$NIX_STORE_DIR"
|
||||
rm -rf "$NIX_STATE_DIR"
|
||||
mkdir "$NIX_STATE_DIR"
|
||||
nix-store --init
|
||||
clearProfiles
|
||||
}
|
||||
|
||||
clearCache() {
|
||||
rm -rf "$cacheDir"
|
||||
}
|
||||
|
||||
clearCacheCache() {
|
||||
rm -f $TEST_HOME/.cache/nix/binary-cache*
|
||||
}
|
||||
|
||||
startDaemon() {
|
||||
# Start the daemon, wait for the socket to appear. !!!
|
||||
# ‘nix-daemon’ should have an option to fork into the background.
|
||||
rm -f $NIX_STATE_DIR/daemon-socket/socket
|
||||
nix-daemon &
|
||||
for ((i = 0; i < 30; i++)); do
|
||||
if [ -e $NIX_STATE_DIR/daemon-socket/socket ]; then break; fi
|
||||
sleep 1
|
||||
done
|
||||
pidDaemon=$!
|
||||
trap "kill -9 $pidDaemon" EXIT
|
||||
export NIX_REMOTE=daemon
|
||||
}
|
||||
|
||||
killDaemon() {
|
||||
kill -9 $pidDaemon
|
||||
wait $pidDaemon || true
|
||||
trap "" EXIT
|
||||
}
|
||||
|
||||
if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true; then
|
||||
_canUseSandbox=1
|
||||
fi
|
||||
|
||||
canUseSandbox() {
|
||||
if [[ ! $_canUseSandbox ]]; then
|
||||
echo "Sandboxing not supported, skipping this test..."
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
expect() {
|
||||
local expected res
|
||||
expected="$1"
|
||||
shift
|
||||
set +e
|
||||
"$@"
|
||||
res="$?"
|
||||
set -e
|
||||
[[ $res -eq $expected ]]
|
||||
}
|
||||
|
||||
set -x
|
||||
20
third_party/nix/tests/config.nix
vendored
Normal file
20
third_party/nix/tests/config.nix
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
with import <nix/config.nix>;
|
||||
|
||||
rec {
|
||||
inherit shell;
|
||||
|
||||
path = coreutils;
|
||||
|
||||
system = builtins.currentSystem;
|
||||
|
||||
shared = builtins.getEnv "_NIX_TEST_SHARED";
|
||||
|
||||
mkDerivation = args:
|
||||
derivation ({
|
||||
inherit system;
|
||||
builder = shell;
|
||||
args = ["-e" args.builder or (builtins.toFile "builder.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
|
||||
PATH = path;
|
||||
} // removeAttrs args ["builder" "meta"])
|
||||
// { meta = args.meta or {}; };
|
||||
}
|
||||
16
third_party/nix/tests/dependencies.builder0.sh
vendored
Normal file
16
third_party/nix/tests/dependencies.builder0.sh
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[ "${input1: -2}" = /. ]
|
||||
[ "${input2: -2}" = /. ]
|
||||
|
||||
mkdir $out
|
||||
echo $(cat $input1/foo)$(cat $input2/bar) > $out/foobar
|
||||
|
||||
ln -s $input2 $out/input-2
|
||||
|
||||
# Self-reference.
|
||||
ln -s $out $out/self
|
||||
|
||||
# Executable.
|
||||
echo program > $out/program
|
||||
chmod +x $out/program
|
||||
|
||||
echo FOO
|
||||
2
third_party/nix/tests/dependencies.builder1.sh
vendored
Normal file
2
third_party/nix/tests/dependencies.builder1.sh
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mkdir $out
|
||||
echo FOO > $out/foo
|
||||
2
third_party/nix/tests/dependencies.builder2.sh
vendored
Normal file
2
third_party/nix/tests/dependencies.builder2.sh
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mkdir $out
|
||||
echo BAR > $out/bar
|
||||
24
third_party/nix/tests/dependencies.nix
vendored
Normal file
24
third_party/nix/tests/dependencies.nix
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
with import ./config.nix;
|
||||
|
||||
let {
|
||||
|
||||
input1 = mkDerivation {
|
||||
name = "dependencies-input-1";
|
||||
builder = ./dependencies.builder1.sh;
|
||||
};
|
||||
|
||||
input2 = mkDerivation {
|
||||
name = "dependencies-input-2";
|
||||
builder = "${./dependencies.builder2.sh}";
|
||||
};
|
||||
|
||||
body = mkDerivation {
|
||||
name = "dependencies";
|
||||
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
||||
input1 = input1 + "/.";
|
||||
input2 = "${input2}/.";
|
||||
input1_drv = input1;
|
||||
meta.description = "Random test package";
|
||||
};
|
||||
|
||||
}
|
||||
52
third_party/nix/tests/dependencies.sh
vendored
Normal file
52
third_party/nix/tests/dependencies.sh
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
drvPath=$(nix-instantiate dependencies.nix)
|
||||
|
||||
echo "derivation is $drvPath"
|
||||
|
||||
nix-store -q --tree "$drvPath" | grep ' +---.*builder1.sh'
|
||||
|
||||
# Test Graphviz graph generation.
|
||||
nix-store -q --graph "$drvPath" > $TEST_ROOT/graph
|
||||
if test -n "$dot"; then
|
||||
# Does it parse?
|
||||
$dot < $TEST_ROOT/graph
|
||||
fi
|
||||
|
||||
outPath=$(nix-store -rvv "$drvPath") || fail "build failed"
|
||||
|
||||
# Test Graphviz graph generation.
|
||||
nix-store -q --graph "$outPath" > $TEST_ROOT/graph
|
||||
if test -n "$dot"; then
|
||||
# Does it parse?
|
||||
$dot < $TEST_ROOT/graph
|
||||
fi
|
||||
|
||||
nix-store -q --tree "$outPath" | grep '+---.*dependencies-input-2'
|
||||
|
||||
echo "output path is $outPath"
|
||||
|
||||
text=$(cat "$outPath"/foobar)
|
||||
if test "$text" != "FOOBAR"; then exit 1; fi
|
||||
|
||||
deps=$(nix-store -quR "$drvPath")
|
||||
|
||||
echo "output closure contains $deps"
|
||||
|
||||
# The output path should be in the closure.
|
||||
echo "$deps" | grep -q "$outPath"
|
||||
|
||||
# Input-1 is not retained.
|
||||
if echo "$deps" | grep -q "dependencies-input-1"; then exit 1; fi
|
||||
|
||||
# Input-2 is retained.
|
||||
input2OutPath=$(echo "$deps" | grep "dependencies-input-2")
|
||||
|
||||
# The referrers closure of input-2 should include outPath.
|
||||
nix-store -q --referrers-closure "$input2OutPath" | grep "$outPath"
|
||||
|
||||
# Check that the derivers are set properly.
|
||||
test $(nix-store -q --deriver "$outPath") = "$drvPath"
|
||||
nix-store -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"
|
||||
20
third_party/nix/tests/dump-db.sh
vendored
Normal file
20
third_party/nix/tests/dump-db.sh
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
path=$(nix-build dependencies.nix -o $TEST_ROOT/result)
|
||||
|
||||
deps="$(nix-store -qR $TEST_ROOT/result)"
|
||||
|
||||
nix-store --dump-db > $TEST_ROOT/dump
|
||||
|
||||
rm -rf $NIX_STATE_DIR/db
|
||||
|
||||
nix-store --load-db < $TEST_ROOT/dump
|
||||
|
||||
deps2="$(nix-store -qR $TEST_ROOT/result)"
|
||||
|
||||
[ "$deps" = "$deps2" ];
|
||||
|
||||
nix-store --dump-db > $TEST_ROOT/dump2
|
||||
cmp $TEST_ROOT/dump $TEST_ROOT/dump2
|
||||
29
third_party/nix/tests/export-graph.nix
vendored
Normal file
29
third_party/nix/tests/export-graph.nix
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
printRefs =
|
||||
''
|
||||
echo $exportReferencesGraph
|
||||
while read path; do
|
||||
read drv
|
||||
read nrRefs
|
||||
echo "$path has $nrRefs references"
|
||||
echo "$path" >> $out
|
||||
for ((n = 0; n < $nrRefs; n++)); do read ref; echo "ref $ref"; test -e "$ref"; done
|
||||
done < refs
|
||||
'';
|
||||
|
||||
foo."bar.runtimeGraph" = mkDerivation {
|
||||
name = "dependencies";
|
||||
builder = builtins.toFile "build-graph-builder" "${printRefs}";
|
||||
exportReferencesGraph = ["refs" (import ./dependencies.nix)];
|
||||
};
|
||||
|
||||
foo."bar.buildGraph" = mkDerivation {
|
||||
name = "dependencies";
|
||||
builder = builtins.toFile "build-graph-builder" "${printRefs}";
|
||||
exportReferencesGraph = ["refs" (import ./dependencies.nix).drvPath];
|
||||
};
|
||||
|
||||
}
|
||||
30
third_party/nix/tests/export-graph.sh
vendored
Normal file
30
third_party/nix/tests/export-graph.sh
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
clearProfiles
|
||||
|
||||
checkRef() {
|
||||
nix-store -q --references $TEST_ROOT/result | grep -q "$1" || fail "missing reference $1"
|
||||
}
|
||||
|
||||
# Test the export of the runtime dependency graph.
|
||||
|
||||
outPath=$(nix-build ./export-graph.nix -A 'foo."bar.runtimeGraph"' -o $TEST_ROOT/result)
|
||||
|
||||
test $(nix-store -q --references $TEST_ROOT/result | wc -l) = 2 || fail "bad nr of references"
|
||||
|
||||
checkRef input-2
|
||||
for i in $(cat $outPath); do checkRef $i; done
|
||||
|
||||
# Test the export of the build-time dependency graph.
|
||||
|
||||
nix-store --gc # should force rebuild of input-1
|
||||
|
||||
outPath=$(nix-build ./export-graph.nix -A 'foo."bar.buildGraph"' -o $TEST_ROOT/result)
|
||||
|
||||
checkRef input-1
|
||||
checkRef input-1.drv
|
||||
checkRef input-2
|
||||
checkRef input-2.drv
|
||||
|
||||
for i in $(cat $outPath); do checkRef $i; done
|
||||
36
third_party/nix/tests/export.sh
vendored
Normal file
36
third_party/nix/tests/export.sh
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
outPath=$(nix-build dependencies.nix --no-out-link)
|
||||
|
||||
nix-store --export $outPath > $TEST_ROOT/exp
|
||||
|
||||
nix-store --export $(nix-store -qR $outPath) > $TEST_ROOT/exp_all
|
||||
|
||||
if nix-store --export $outPath >/dev/full ; then
|
||||
echo "exporting to a bad file descriptor should fail"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
clearStore
|
||||
|
||||
if nix-store --import < $TEST_ROOT/exp; then
|
||||
echo "importing a non-closure should fail"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
clearStore
|
||||
|
||||
nix-store --import < $TEST_ROOT/exp_all
|
||||
|
||||
nix-store --export $(nix-store -qR $outPath) > $TEST_ROOT/exp_all2
|
||||
|
||||
|
||||
clearStore
|
||||
|
||||
# Regression test: the derivers in exp_all2 are empty, which shouldn't
|
||||
# cause a failure.
|
||||
nix-store --import < $TEST_ROOT/exp_all2
|
||||
141
third_party/nix/tests/fetchGit.sh
vendored
Normal file
141
third_party/nix/tests/fetchGit.sh
vendored
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
source common.sh
|
||||
|
||||
if [[ -z $(type -p git) ]]; then
|
||||
echo "Git not installed; skipping Git tests"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
clearStore
|
||||
|
||||
repo=$TEST_ROOT/git
|
||||
|
||||
rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/gitv2
|
||||
|
||||
git init $repo
|
||||
git -C $repo config user.email "foobar@example.com"
|
||||
git -C $repo config user.name "Foobar"
|
||||
|
||||
echo utrecht > $repo/hello
|
||||
touch $repo/.gitignore
|
||||
git -C $repo add hello .gitignore
|
||||
git -C $repo commit -m 'Bla1'
|
||||
rev1=$(git -C $repo rev-parse HEAD)
|
||||
|
||||
echo world > $repo/hello
|
||||
git -C $repo commit -m 'Bla2' -a
|
||||
rev2=$(git -C $repo rev-parse HEAD)
|
||||
|
||||
# Fetch the default branch.
|
||||
path=$(nix eval --raw "(builtins.fetchGit file://$repo).outPath")
|
||||
[[ $(cat $path/hello) = world ]]
|
||||
|
||||
# In pure eval mode, fetchGit without a revision should fail.
|
||||
[[ $(nix eval --raw "(builtins.readFile (fetchGit file://$repo + \"/hello\"))") = world ]]
|
||||
(! nix eval --pure-eval --raw "(builtins.readFile (fetchGit file://$repo + \"/hello\"))")
|
||||
|
||||
# Fetch using an explicit revision hash.
|
||||
path2=$(nix eval --raw "(builtins.fetchGit { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
# In pure eval mode, fetchGit with a revision should succeed.
|
||||
[[ $(nix eval --pure-eval --raw "(builtins.readFile (fetchGit { url = file://$repo; rev = \"$rev2\"; } + \"/hello\"))") = world ]]
|
||||
|
||||
# Fetch again. This should be cached.
|
||||
mv $repo ${repo}-tmp
|
||||
path2=$(nix eval --raw "(builtins.fetchGit file://$repo).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
[[ $(nix eval "(builtins.fetchGit file://$repo).revCount") = 2 ]]
|
||||
[[ $(nix eval --raw "(builtins.fetchGit file://$repo).rev") = $rev2 ]]
|
||||
|
||||
# But with TTL 0, it should fail.
|
||||
(! nix eval --tarball-ttl 0 "(builtins.fetchGit file://$repo)" -vvvvv)
|
||||
|
||||
# Fetching with a explicit hash should succeed.
|
||||
path2=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchGit { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
path2=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchGit { url = file://$repo; rev = \"$rev1\"; }).outPath")
|
||||
[[ $(cat $path2/hello) = utrecht ]]
|
||||
|
||||
mv ${repo}-tmp $repo
|
||||
|
||||
# Using a clean working tree should produce the same result.
|
||||
path2=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
# Using an unclean tree should yield the tracked but uncommitted changes.
|
||||
mkdir $repo/dir1 $repo/dir2
|
||||
echo foo > $repo/dir1/foo
|
||||
echo bar > $repo/bar
|
||||
echo bar > $repo/dir2/bar
|
||||
git -C $repo add dir1/foo
|
||||
git -C $repo rm hello
|
||||
|
||||
path2=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
|
||||
[ ! -e $path2/hello ]
|
||||
[ ! -e $path2/bar ]
|
||||
[ ! -e $path2/dir2/bar ]
|
||||
[ ! -e $path2/.git ]
|
||||
[[ $(cat $path2/dir1/foo) = foo ]]
|
||||
|
||||
[[ $(nix eval --raw "(builtins.fetchGit $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
||||
|
||||
# ... unless we're using an explicit ref or rev.
|
||||
path3=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"master\"; }).outPath")
|
||||
[[ $path = $path3 ]]
|
||||
|
||||
path3=$(nix eval --raw "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; }).outPath")
|
||||
[[ $path = $path3 ]]
|
||||
|
||||
# Committing should not affect the store path.
|
||||
git -C $repo commit -m 'Bla3' -a
|
||||
|
||||
path4=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchGit file://$repo).outPath")
|
||||
[[ $path2 = $path4 ]]
|
||||
|
||||
# tarball-ttl should be ignored if we specify a rev
|
||||
echo delft > $repo/hello
|
||||
git -C $repo add hello
|
||||
git -C $repo commit -m 'Bla4'
|
||||
rev3=$(git -C $repo rev-parse HEAD)
|
||||
nix eval --tarball-ttl 3600 "(builtins.fetchGit { url = $repo; rev = \"$rev3\"; })" >/dev/null
|
||||
|
||||
# Update 'path' to reflect latest master
|
||||
path=$(nix eval --raw "(builtins.fetchGit file://$repo).outPath")
|
||||
|
||||
# Check behavior when non-master branch is used
|
||||
git -C $repo checkout $rev2 -b dev
|
||||
echo dev > $repo/hello
|
||||
|
||||
# File URI uses 'master' unless specified otherwise
|
||||
path2=$(nix eval --raw "(builtins.fetchGit file://$repo).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
# Using local path with branch other than 'master' should work when clean or dirty
|
||||
path3=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
|
||||
# (check dirty-tree handling was used)
|
||||
[[ $(nix eval --raw "(builtins.fetchGit $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
||||
|
||||
# Committing shouldn't change store path, or switch to using 'master'
|
||||
git -C $repo commit -m 'Bla5' -a
|
||||
path4=$(nix eval --raw "(builtins.fetchGit $repo).outPath")
|
||||
[[ $(cat $path4/hello) = dev ]]
|
||||
[[ $path3 = $path4 ]]
|
||||
|
||||
# Confirm same as 'dev' branch
|
||||
path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath")
|
||||
[[ $path3 = $path5 ]]
|
||||
|
||||
|
||||
# Nuke the cache
|
||||
rm -rf $TEST_HOME/.cache/nix/gitv2
|
||||
|
||||
# Try again, but without 'git' on PATH
|
||||
NIX=$(command -v nix)
|
||||
# This should fail
|
||||
(! PATH= $NIX eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath" )
|
||||
|
||||
# Try again, with 'git' available. This should work.
|
||||
path5=$(nix eval --raw "(builtins.fetchGit { url = $repo; ref = \"dev\"; }).outPath")
|
||||
[[ $path3 = $path5 ]]
|
||||
93
third_party/nix/tests/fetchMercurial.sh
vendored
Normal file
93
third_party/nix/tests/fetchMercurial.sh
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
source common.sh
|
||||
|
||||
if [[ -z $(type -p hg) ]]; then
|
||||
echo "Mercurial not installed; skipping Mercurial tests"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
clearStore
|
||||
|
||||
repo=$TEST_ROOT/hg
|
||||
|
||||
rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/hg
|
||||
|
||||
hg init $repo
|
||||
echo '[ui]' >> $repo/.hg/hgrc
|
||||
echo 'username = Foobar <foobar@example.org>' >> $repo/.hg/hgrc
|
||||
|
||||
echo utrecht > $repo/hello
|
||||
touch $repo/.hgignore
|
||||
hg add --cwd $repo hello .hgignore
|
||||
hg commit --cwd $repo -m 'Bla1'
|
||||
rev1=$(hg log --cwd $repo -r tip --template '{node}')
|
||||
|
||||
echo world > $repo/hello
|
||||
hg commit --cwd $repo -m 'Bla2'
|
||||
rev2=$(hg log --cwd $repo -r tip --template '{node}')
|
||||
|
||||
# Fetch the default branch.
|
||||
path=$(nix eval --raw "(builtins.fetchMercurial file://$repo).outPath")
|
||||
[[ $(cat $path/hello) = world ]]
|
||||
|
||||
# In pure eval mode, fetchGit without a revision should fail.
|
||||
[[ $(nix eval --raw "(builtins.readFile (fetchMercurial file://$repo + \"/hello\"))") = world ]]
|
||||
(! nix eval --pure-eval --raw "(builtins.readFile (fetchMercurial file://$repo + \"/hello\"))")
|
||||
|
||||
# Fetch using an explicit revision hash.
|
||||
path2=$(nix eval --raw "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
# In pure eval mode, fetchGit with a revision should succeed.
|
||||
[[ $(nix eval --pure-eval --raw "(builtins.readFile (fetchMercurial { url = file://$repo; rev = \"$rev2\"; } + \"/hello\"))") = world ]]
|
||||
|
||||
# Fetch again. This should be cached.
|
||||
mv $repo ${repo}-tmp
|
||||
path2=$(nix eval --raw "(builtins.fetchMercurial file://$repo).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
[[ $(nix eval --raw "(builtins.fetchMercurial file://$repo).branch") = default ]]
|
||||
[[ $(nix eval "(builtins.fetchMercurial file://$repo).revCount") = 1 ]]
|
||||
[[ $(nix eval --raw "(builtins.fetchMercurial file://$repo).rev") = $rev2 ]]
|
||||
|
||||
# But with TTL 0, it should fail.
|
||||
(! nix eval --tarball-ttl 0 "(builtins.fetchMercurial file://$repo)")
|
||||
|
||||
# Fetching with a explicit hash should succeed.
|
||||
path2=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
path2=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev1\"; }).outPath")
|
||||
[[ $(cat $path2/hello) = utrecht ]]
|
||||
|
||||
mv ${repo}-tmp $repo
|
||||
|
||||
# Using a clean working tree should produce the same result.
|
||||
path2=$(nix eval --raw "(builtins.fetchMercurial $repo).outPath")
|
||||
[[ $path = $path2 ]]
|
||||
|
||||
# Using an unclean tree should yield the tracked but uncommitted changes.
|
||||
mkdir $repo/dir1 $repo/dir2
|
||||
echo foo > $repo/dir1/foo
|
||||
echo bar > $repo/bar
|
||||
echo bar > $repo/dir2/bar
|
||||
hg add --cwd $repo dir1/foo
|
||||
hg rm --cwd $repo hello
|
||||
|
||||
path2=$(nix eval --raw "(builtins.fetchMercurial $repo).outPath")
|
||||
[ ! -e $path2/hello ]
|
||||
[ ! -e $path2/bar ]
|
||||
[ ! -e $path2/dir2/bar ]
|
||||
[ ! -e $path2/.hg ]
|
||||
[[ $(cat $path2/dir1/foo) = foo ]]
|
||||
|
||||
[[ $(nix eval --raw "(builtins.fetchMercurial $repo).rev") = 0000000000000000000000000000000000000000 ]]
|
||||
|
||||
# ... unless we're using an explicit rev.
|
||||
path3=$(nix eval --raw "(builtins.fetchMercurial { url = $repo; rev = \"default\"; }).outPath")
|
||||
[[ $path = $path3 ]]
|
||||
|
||||
# Committing should not affect the store path.
|
||||
hg commit --cwd $repo -m 'Bla3'
|
||||
|
||||
path4=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchMercurial file://$repo).outPath")
|
||||
[[ $path2 = $path4 ]]
|
||||
78
third_party/nix/tests/fetchurl.sh
vendored
Normal file
78
third_party/nix/tests/fetchurl.sh
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
# Test fetching a flat file.
|
||||
hash=$(nix-hash --flat --type sha256 ./fetchurl.sh)
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr sha256 $hash --no-out-link --hashed-mirrors '')
|
||||
|
||||
cmp $outPath fetchurl.sh
|
||||
|
||||
# Now using a base-64 hash.
|
||||
clearStore
|
||||
|
||||
hash=$(nix hash-file --type sha512 --base64 ./fetchurl.sh)
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr sha512 $hash --no-out-link --hashed-mirrors '')
|
||||
|
||||
cmp $outPath fetchurl.sh
|
||||
|
||||
# Now using an SRI hash.
|
||||
clearStore
|
||||
|
||||
hash=$(nix hash-file ./fetchurl.sh)
|
||||
|
||||
[[ $hash =~ ^sha256- ]]
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr hash $hash --no-out-link --hashed-mirrors '')
|
||||
|
||||
cmp $outPath fetchurl.sh
|
||||
|
||||
# Test the hashed mirror feature.
|
||||
clearStore
|
||||
|
||||
hash=$(nix hash-file --type sha512 --base64 ./fetchurl.sh)
|
||||
hash32=$(nix hash-file --type sha512 --base16 ./fetchurl.sh)
|
||||
|
||||
mirror=$TMPDIR/hashed-mirror
|
||||
rm -rf $mirror
|
||||
mkdir -p $mirror/sha512
|
||||
ln -s $(pwd)/fetchurl.sh $mirror/sha512/$hash32
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr sha512 $hash --no-out-link --hashed-mirrors "file://$mirror")
|
||||
|
||||
# Test hashed mirrors with an SRI hash.
|
||||
nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr hash $(nix to-sri --type sha512 $hash) \
|
||||
--argstr name bla --no-out-link --hashed-mirrors "file://$mirror"
|
||||
|
||||
# Test unpacking a NAR.
|
||||
rm -rf $TEST_ROOT/archive
|
||||
mkdir -p $TEST_ROOT/archive
|
||||
cp ./fetchurl.sh $TEST_ROOT/archive
|
||||
chmod +x $TEST_ROOT/archive/fetchurl.sh
|
||||
ln -s foo $TEST_ROOT/archive/symlink
|
||||
nar=$TEST_ROOT/archive.nar
|
||||
nix-store --dump $TEST_ROOT/archive > $nar
|
||||
|
||||
hash=$(nix-hash --flat --type sha256 $nar)
|
||||
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$nar --argstr sha256 $hash \
|
||||
--arg unpack true --argstr name xyzzy --no-out-link)
|
||||
|
||||
echo $outPath | grep -q 'xyzzy'
|
||||
|
||||
test -x $outPath/fetchurl.sh
|
||||
test -L $outPath/symlink
|
||||
|
||||
nix-store --delete $outPath
|
||||
|
||||
# Test unpacking a compressed NAR.
|
||||
narxz=$TEST_ROOT/archive.nar.xz
|
||||
rm -f $narxz
|
||||
xz --keep $nar
|
||||
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$narxz --argstr sha256 $hash \
|
||||
--arg unpack true --argstr name xyzzy --no-out-link)
|
||||
|
||||
test -x $outPath/fetchurl.sh
|
||||
test -L $outPath/symlink
|
||||
12
third_party/nix/tests/filter-source.nix
vendored
Normal file
12
third_party/nix/tests/filter-source.nix
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "filter";
|
||||
builder = builtins.toFile "builder" "ln -s $input $out";
|
||||
input =
|
||||
let filter = path: type:
|
||||
type != "symlink"
|
||||
&& baseNameOf path != "foo"
|
||||
&& !((import ./lang/lib.nix).hasSuffix ".bak" (baseNameOf path));
|
||||
in builtins.filterSource filter ((builtins.getEnv "TEST_ROOT") + "/filterin");
|
||||
}
|
||||
19
third_party/nix/tests/filter-source.sh
vendored
Normal file
19
third_party/nix/tests/filter-source.sh
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
source common.sh
|
||||
|
||||
rm -rf $TEST_ROOT/filterin
|
||||
mkdir $TEST_ROOT/filterin
|
||||
mkdir $TEST_ROOT/filterin/foo
|
||||
touch $TEST_ROOT/filterin/foo/bar
|
||||
touch $TEST_ROOT/filterin/xyzzy
|
||||
touch $TEST_ROOT/filterin/b
|
||||
touch $TEST_ROOT/filterin/bak
|
||||
touch $TEST_ROOT/filterin/bla.c.bak
|
||||
ln -s xyzzy $TEST_ROOT/filterin/link
|
||||
|
||||
nix-build ./filter-source.nix -o $TEST_ROOT/filterout
|
||||
|
||||
test ! -e $TEST_ROOT/filterout/foo/bar
|
||||
test -e $TEST_ROOT/filterout/xyzzy
|
||||
test -e $TEST_ROOT/filterout/bak
|
||||
test ! -e $TEST_ROOT/filterout/bla.c.bak
|
||||
test ! -L $TEST_ROOT/filterout/link
|
||||
3
third_party/nix/tests/fixed.builder1.sh
vendored
Normal file
3
third_party/nix/tests/fixed.builder1.sh
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if test "$IMPURE_VAR1" != "foo"; then exit 1; fi
|
||||
if test "$IMPURE_VAR2" != "bar"; then exit 1; fi
|
||||
echo "Hello World!" > $out
|
||||
6
third_party/nix/tests/fixed.builder2.sh
vendored
Normal file
6
third_party/nix/tests/fixed.builder2.sh
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
echo dummy: $dummy
|
||||
if test -n "$dummy"; then sleep 2; fi
|
||||
mkdir $out
|
||||
mkdir $out/bla
|
||||
echo "Hello World!" > $out/foo
|
||||
ln -s foo $out/bar
|
||||
50
third_party/nix/tests/fixed.nix
vendored
Normal file
50
third_party/nix/tests/fixed.nix
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
f2 = dummy: builder: mode: algo: hash: mkDerivation {
|
||||
name = "fixed";
|
||||
inherit builder;
|
||||
outputHashMode = mode;
|
||||
outputHashAlgo = algo;
|
||||
outputHash = hash;
|
||||
inherit dummy;
|
||||
impureEnvVars = ["IMPURE_VAR1" "IMPURE_VAR2"];
|
||||
};
|
||||
|
||||
f = f2 "";
|
||||
|
||||
good = [
|
||||
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
||||
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
||||
(f ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||
(f ./fixed.builder2.sh "recursive" "sha1" "vw46m23bizj4n8afrc0fj19wrp7mj3c0")
|
||||
];
|
||||
|
||||
good2 = [
|
||||
# Yes, this looks fscked up: builder2 doesn't have that result.
|
||||
# But Nix sees that an output with the desired hash already
|
||||
# exists, and will refrain from building it.
|
||||
(f ./fixed.builder2.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
||||
];
|
||||
|
||||
sameAsAdd =
|
||||
f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik";
|
||||
|
||||
bad = [
|
||||
(f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858")
|
||||
];
|
||||
|
||||
reallyBad = [
|
||||
# Hash too short, and not base-32 either.
|
||||
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
||||
];
|
||||
|
||||
# Test for building two derivations in parallel that produce the
|
||||
# same output path because they're fixed-output derivations.
|
||||
parallelSame = [
|
||||
(f2 "foo" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||
(f2 "bar" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||
];
|
||||
|
||||
}
|
||||
56
third_party/nix/tests/fixed.sh
vendored
Normal file
56
third_party/nix/tests/fixed.sh
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
export IMPURE_VAR1=foo
|
||||
export IMPURE_VAR2=bar
|
||||
|
||||
path=$(nix-store -q $(nix-instantiate fixed.nix -A good.0))
|
||||
|
||||
echo 'testing bad...'
|
||||
nix-build fixed.nix -A bad --no-out-link && fail "should fail"
|
||||
|
||||
# Building with the bad hash should produce the "good" output path as
|
||||
# a side-effect.
|
||||
[[ -e $path ]]
|
||||
nix path-info --json $path | grep fixed:md5:2qk15sxzzjlnpjk9brn7j8ppcd
|
||||
|
||||
echo 'testing good...'
|
||||
nix-build fixed.nix -A good --no-out-link
|
||||
|
||||
echo 'testing good2...'
|
||||
nix-build fixed.nix -A good2 --no-out-link
|
||||
|
||||
echo 'testing reallyBad...'
|
||||
nix-instantiate fixed.nix -A reallyBad && fail "should fail"
|
||||
|
||||
# While we're at it, check attribute selection a bit more.
|
||||
echo 'testing attribute selection...'
|
||||
test $(nix-instantiate fixed.nix -A good.1 | wc -l) = 1
|
||||
|
||||
# Test parallel builds of derivations that produce the same output.
|
||||
# Only one should run at the same time.
|
||||
echo 'testing parallelSame...'
|
||||
clearStore
|
||||
nix-build fixed.nix -A parallelSame --no-out-link -j2
|
||||
|
||||
# Fixed-output derivations with a recursive SHA-256 hash should
|
||||
# produce the same path as "nix-store --add".
|
||||
echo 'testing sameAsAdd...'
|
||||
out=$(nix-build fixed.nix -A sameAsAdd --no-out-link)
|
||||
|
||||
# This is what fixed.builder2 produces...
|
||||
rm -rf $TEST_ROOT/fixed
|
||||
mkdir $TEST_ROOT/fixed
|
||||
mkdir $TEST_ROOT/fixed/bla
|
||||
echo "Hello World!" > $TEST_ROOT/fixed/foo
|
||||
ln -s foo $TEST_ROOT/fixed/bar
|
||||
|
||||
out2=$(nix-store --add $TEST_ROOT/fixed)
|
||||
[ "$out" = "$out2" ]
|
||||
|
||||
out3=$(nix-store --add-fixed --recursive sha256 $TEST_ROOT/fixed)
|
||||
[ "$out" = "$out3" ]
|
||||
|
||||
out4=$(nix-store --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed)
|
||||
[ "$out" = "$out4" ]
|
||||
85
third_party/nix/tests/function-trace.sh
vendored
Executable file
85
third_party/nix/tests/function-trace.sh
vendored
Executable file
|
|
@ -0,0 +1,85 @@
|
|||
source common.sh
|
||||
|
||||
set +x
|
||||
|
||||
expect_trace() {
|
||||
expr="$1"
|
||||
expect="$2"
|
||||
actual=$(
|
||||
nix-instantiate \
|
||||
--trace-function-calls \
|
||||
--expr "$expr" 2>&1 \
|
||||
| grep "function-trace" \
|
||||
| sed -e 's/ [0-9]*$//'
|
||||
);
|
||||
|
||||
echo -n "Tracing expression '$expr'"
|
||||
set +e
|
||||
msg=$(diff -swB \
|
||||
<(echo "$expect") \
|
||||
<(echo "$actual")
|
||||
);
|
||||
result=$?
|
||||
set -e
|
||||
if [ $result -eq 0 ]; then
|
||||
echo " ok."
|
||||
else
|
||||
echo " failed. difference:"
|
||||
echo "$msg"
|
||||
return $result
|
||||
fi
|
||||
}
|
||||
|
||||
# failure inside a tryEval
|
||||
expect_trace 'builtins.tryEval (throw "example")' "
|
||||
function-trace entered undefined position at
|
||||
function-trace exited undefined position at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace entered (string):1:19 at
|
||||
function-trace exited (string):1:19 at
|
||||
function-trace exited (string):1:1 at
|
||||
"
|
||||
|
||||
# Missing argument to a formal function
|
||||
expect_trace '({ x }: x) { }' "
|
||||
function-trace entered undefined position at
|
||||
function-trace exited undefined position at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace exited (string):1:1 at
|
||||
"
|
||||
|
||||
# Too many arguments to a formal function
|
||||
expect_trace '({ x }: x) { x = "x"; y = "y"; }' "
|
||||
function-trace entered undefined position at
|
||||
function-trace exited undefined position at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace exited (string):1:1 at
|
||||
"
|
||||
|
||||
# Not enough arguments to a lambda
|
||||
expect_trace '(x: y: x + y) 1' "
|
||||
function-trace entered undefined position at
|
||||
function-trace exited undefined position at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace exited (string):1:1 at
|
||||
"
|
||||
|
||||
# Too many arguments to a lambda
|
||||
expect_trace '(x: x) 1 2' "
|
||||
function-trace entered undefined position at
|
||||
function-trace exited undefined position at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace exited (string):1:1 at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace exited (string):1:1 at
|
||||
"
|
||||
|
||||
# Not a function
|
||||
expect_trace '1 2' "
|
||||
function-trace entered undefined position at
|
||||
function-trace exited undefined position at
|
||||
function-trace entered (string):1:1 at
|
||||
function-trace exited (string):1:1 at
|
||||
"
|
||||
|
||||
set -e
|
||||
70
third_party/nix/tests/gc-auto.sh
vendored
Normal file
70
third_party/nix/tests/gc-auto.sh
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
garbage1=$(nix add-to-store --name garbage1 ./nar-access.sh)
|
||||
garbage2=$(nix add-to-store --name garbage2 ./nar-access.sh)
|
||||
garbage3=$(nix add-to-store --name garbage3 ./nar-access.sh)
|
||||
|
||||
ls -l $garbage3
|
||||
POSIXLY_CORRECT=1 du $garbage3
|
||||
|
||||
fake_free=$TEST_ROOT/fake-free
|
||||
export _NIX_TEST_FREE_SPACE_FILE=$fake_free
|
||||
echo 1100 > $fake_free
|
||||
|
||||
expr=$(cat <<EOF
|
||||
with import ./config.nix; mkDerivation {
|
||||
name = "gc-A";
|
||||
buildCommand = ''
|
||||
set -x
|
||||
[[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 3 ]]
|
||||
mkdir \$out
|
||||
echo foo > \$out/bar
|
||||
echo 1...
|
||||
sleep 2
|
||||
echo 200 > ${fake_free}.tmp1
|
||||
mv ${fake_free}.tmp1 $fake_free
|
||||
echo 2...
|
||||
sleep 2
|
||||
echo 3...
|
||||
sleep 2
|
||||
echo 4...
|
||||
[[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 1 ]]
|
||||
'';
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
expr2=$(cat <<EOF
|
||||
with import ./config.nix; mkDerivation {
|
||||
name = "gc-B";
|
||||
buildCommand = ''
|
||||
set -x
|
||||
mkdir \$out
|
||||
echo foo > \$out/bar
|
||||
echo 1...
|
||||
sleep 2
|
||||
echo 200 > ${fake_free}.tmp2
|
||||
mv ${fake_free}.tmp2 $fake_free
|
||||
echo 2...
|
||||
sleep 2
|
||||
echo 3...
|
||||
sleep 2
|
||||
echo 4...
|
||||
'';
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
nix build -v -o $TEST_ROOT/result-A -L "($expr)" \
|
||||
--min-free 1000 --max-free 2000 --min-free-check-interval 1 &
|
||||
pid=$!
|
||||
|
||||
nix build -v -o $TEST_ROOT/result-B -L "($expr2)" \
|
||||
--min-free 1000 --max-free 2000 --min-free-check-interval 1
|
||||
|
||||
wait "$pid"
|
||||
|
||||
[[ foo = $(cat $TEST_ROOT/result-A/bar) ]]
|
||||
[[ foo = $(cat $TEST_ROOT/result-B/bar) ]]
|
||||
13
third_party/nix/tests/gc-concurrent.builder.sh
vendored
Normal file
13
third_party/nix/tests/gc-concurrent.builder.sh
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
mkdir $out
|
||||
echo $(cat $input1/foo)$(cat $input2/bar) > $out/foobar
|
||||
|
||||
sleep 10
|
||||
|
||||
# $out should not have been GC'ed while we were sleeping, but just in
|
||||
# case...
|
||||
mkdir -p $out
|
||||
|
||||
# Check that the GC hasn't deleted the lock on our output.
|
||||
test -e "$out.lock"
|
||||
|
||||
ln -s $input2 $out/input-2
|
||||
27
third_party/nix/tests/gc-concurrent.nix
vendored
Normal file
27
third_party/nix/tests/gc-concurrent.nix
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
input1 = mkDerivation {
|
||||
name = "dependencies-input-1";
|
||||
builder = ./dependencies.builder1.sh;
|
||||
};
|
||||
|
||||
input2 = mkDerivation {
|
||||
name = "dependencies-input-2";
|
||||
builder = ./dependencies.builder2.sh;
|
||||
};
|
||||
|
||||
test1 = mkDerivation {
|
||||
name = "gc-concurrent";
|
||||
builder = ./gc-concurrent.builder.sh;
|
||||
inherit input1 input2;
|
||||
};
|
||||
|
||||
test2 = mkDerivation {
|
||||
name = "gc-concurrent2";
|
||||
builder = ./gc-concurrent2.builder.sh;
|
||||
inherit input1 input2;
|
||||
};
|
||||
|
||||
}
|
||||
58
third_party/nix/tests/gc-concurrent.sh
vendored
Normal file
58
third_party/nix/tests/gc-concurrent.sh
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
drvPath1=$(nix-instantiate gc-concurrent.nix -A test1)
|
||||
outPath1=$(nix-store -q $drvPath1)
|
||||
|
||||
drvPath2=$(nix-instantiate gc-concurrent.nix -A test2)
|
||||
outPath2=$(nix-store -q $drvPath2)
|
||||
|
||||
drvPath3=$(nix-instantiate simple.nix)
|
||||
outPath3=$(nix-store -r $drvPath3)
|
||||
|
||||
(! test -e $outPath3.lock)
|
||||
touch $outPath3.lock
|
||||
|
||||
rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
||||
ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo
|
||||
ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2
|
||||
|
||||
# Start build #1 in the background. It starts immediately.
|
||||
nix-store -rvv "$drvPath1" &
|
||||
pid1=$!
|
||||
|
||||
# Start build #2 in the background after 10 seconds.
|
||||
(sleep 10 && nix-store -rvv "$drvPath2") &
|
||||
pid2=$!
|
||||
|
||||
# Run the garbage collector while the build is running.
|
||||
sleep 6
|
||||
nix-collect-garbage
|
||||
|
||||
# Wait for build #1/#2 to finish.
|
||||
echo waiting for pid $pid1 to finish...
|
||||
wait $pid1
|
||||
echo waiting for pid $pid2 to finish...
|
||||
wait $pid2
|
||||
|
||||
# Check that the root of build #1 and its dependencies haven't been
|
||||
# deleted. The should not be deleted by the GC because they were
|
||||
# being built during the GC.
|
||||
cat $outPath1/foobar
|
||||
cat $outPath1/input-2/bar
|
||||
|
||||
# Check that build #2 has succeeded. It should succeed because the
|
||||
# derivation is a GC root.
|
||||
cat $outPath2/foobar
|
||||
|
||||
rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
||||
|
||||
# The collector should have deleted lock files for paths that have
|
||||
# been built previously.
|
||||
(! test -e $outPath3.lock)
|
||||
|
||||
# If we run the collector now, it should delete outPath1/2.
|
||||
nix-collect-garbage
|
||||
(! test -e $outPath1)
|
||||
(! test -e $outPath2)
|
||||
7
third_party/nix/tests/gc-concurrent2.builder.sh
vendored
Normal file
7
third_party/nix/tests/gc-concurrent2.builder.sh
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
mkdir $out
|
||||
echo $(cat $input1/foo)$(cat $input2/bar)xyzzy > $out/foobar
|
||||
|
||||
# Check that the GC hasn't deleted the lock on our output.
|
||||
test -e "$out.lock"
|
||||
|
||||
sleep 6
|
||||
17
third_party/nix/tests/gc-runtime.nix
vendored
Normal file
17
third_party/nix/tests/gc-runtime.nix
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "gc-runtime";
|
||||
builder =
|
||||
# Test inline source file definitions.
|
||||
builtins.toFile "builder.sh" ''
|
||||
mkdir $out
|
||||
|
||||
cat > $out/program <<EOF
|
||||
#! ${shell}
|
||||
sleep 10000
|
||||
EOF
|
||||
|
||||
chmod +x $out/program
|
||||
'';
|
||||
}
|
||||
38
third_party/nix/tests/gc-runtime.sh
vendored
Normal file
38
third_party/nix/tests/gc-runtime.sh
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
source common.sh
|
||||
|
||||
case $system in
|
||||
*linux*)
|
||||
;;
|
||||
*)
|
||||
exit 0;
|
||||
esac
|
||||
|
||||
set -m # enable job control, needed for kill
|
||||
|
||||
profiles="$NIX_STATE_DIR"/profiles
|
||||
rm -rf $profiles
|
||||
|
||||
nix-env -p $profiles/test -f ./gc-runtime.nix -i gc-runtime
|
||||
|
||||
outPath=$(nix-env -p $profiles/test -q --no-name --out-path gc-runtime)
|
||||
echo $outPath
|
||||
|
||||
echo "backgrounding program..."
|
||||
$profiles/test/program &
|
||||
sleep 2 # hack - wait for the program to get started
|
||||
child=$!
|
||||
echo PID=$child
|
||||
|
||||
nix-env -p $profiles/test -e gc-runtime
|
||||
nix-env -p $profiles/test --delete-generations old
|
||||
|
||||
nix-store --gc
|
||||
|
||||
kill -- -$child
|
||||
|
||||
if ! test -e $outPath; then
|
||||
echo "running program was garbage collected!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
40
third_party/nix/tests/gc.sh
vendored
Normal file
40
third_party/nix/tests/gc.sh
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
source common.sh
|
||||
|
||||
drvPath=$(nix-instantiate dependencies.nix)
|
||||
outPath=$(nix-store -rvv "$drvPath")
|
||||
|
||||
# Set a GC root.
|
||||
rm -f "$NIX_STATE_DIR"/gcroots/foo
|
||||
ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
|
||||
|
||||
[ "$(nix-store -q --roots $outPath)" = "$NIX_STATE_DIR/gcroots/foo -> $outPath" ]
|
||||
|
||||
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
|
||||
|
||||
nix-store --gc --print-dead
|
||||
|
||||
inUse=$(readLink $outPath/input-2)
|
||||
if nix-store --delete $inUse; then false; fi
|
||||
test -e $inUse
|
||||
|
||||
if nix-store --delete $outPath; then false; fi
|
||||
test -e $outPath
|
||||
|
||||
nix-collect-garbage
|
||||
|
||||
# Check that the root and its dependencies haven't been deleted.
|
||||
cat $outPath/foobar
|
||||
cat $outPath/input-2/bar
|
||||
|
||||
# Check that the derivation has been GC'd.
|
||||
if test -e $drvPath; then false; fi
|
||||
|
||||
rm "$NIX_STATE_DIR"/gcroots/foo
|
||||
|
||||
nix-collect-garbage
|
||||
|
||||
# Check that the output has been GC'd.
|
||||
if test -e $outPath/foobar; then false; fi
|
||||
29
third_party/nix/tests/hash-check.nix
vendored
Normal file
29
third_party/nix/tests/hash-check.nix
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
let {
|
||||
|
||||
input1 = derivation {
|
||||
name = "dependencies-input-1";
|
||||
system = "i086-msdos";
|
||||
builder = "/bar/sh";
|
||||
args = ["-e" "-x" ./dummy];
|
||||
};
|
||||
|
||||
input2 = derivation {
|
||||
name = "dependencies-input-2";
|
||||
system = "i086-msdos";
|
||||
builder = "/bar/sh";
|
||||
args = ["-e" "-x" ./dummy];
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "md5";
|
||||
outputHash = "ffffffffffffffffffffffffffffffff";
|
||||
};
|
||||
|
||||
body = derivation {
|
||||
name = "dependencies";
|
||||
system = "i086-msdos";
|
||||
builder = "/bar/sh";
|
||||
args = ["-e" "-x" (./dummy + "/FOOBAR/../.")];
|
||||
input1 = input1 + "/.";
|
||||
inherit input2;
|
||||
};
|
||||
|
||||
}
|
||||
87
third_party/nix/tests/hash.sh
vendored
Normal file
87
third_party/nix/tests/hash.sh
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
source common.sh
|
||||
|
||||
try () {
|
||||
printf "%s" "$2" > $TEST_ROOT/vector
|
||||
hash=$(nix hash-file --base16 $EXTRA --type "$1" $TEST_ROOT/vector)
|
||||
if test "$hash" != "$3"; then
|
||||
echo "hash $1, expected $3, got $hash"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
try md5 "" "d41d8cd98f00b204e9800998ecf8427e"
|
||||
try md5 "a" "0cc175b9c0f1b6a831c399e269772661"
|
||||
try md5 "abc" "900150983cd24fb0d6963f7d28e17f72"
|
||||
try md5 "message digest" "f96b697d7cb7938d525a2f31aaf161d0"
|
||||
try md5 "abcdefghijklmnopqrstuvwxyz" "c3fcd3d76192e4007dfb496cca67e13b"
|
||||
try md5 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" "d174ab98d277d9f5a5611c2c9f419d9f"
|
||||
try md5 "12345678901234567890123456789012345678901234567890123456789012345678901234567890" "57edf4a22be3c955ac49da2e2107b67a"
|
||||
|
||||
try sha1 "" "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
||||
try sha1 "abc" "a9993e364706816aba3e25717850c26c9cd0d89d"
|
||||
try sha1 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "84983e441c3bd26ebaae4aa1f95129e5e54670f1"
|
||||
|
||||
try sha256 "" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
try sha256 "abc" "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
|
||||
try sha256 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
|
||||
|
||||
try sha512 "" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
|
||||
try sha512 "abc" "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"
|
||||
try sha512 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445"
|
||||
|
||||
EXTRA=--base32
|
||||
try sha256 "abc" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s"
|
||||
EXTRA=
|
||||
|
||||
EXTRA=--sri
|
||||
try sha512 "" "sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg=="
|
||||
try sha512 "abc" "sha512-3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw=="
|
||||
try sha512 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "sha512-IEqPxt2oLwoM7XvrjgikFlfBbvRosiioJ5vjMacDwzWW/RXBOxsH+aodO+pXeJygMa2Fx6cd1wNU7GMSOMo0RQ=="
|
||||
try sha256 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "sha256-JI1qYdIGOLjlwCaTDD5gOaM85Flk/yFn9uzt1BnbBsE="
|
||||
|
||||
try2 () {
|
||||
hash=$(nix-hash --type "$1" $TEST_ROOT/hash-path)
|
||||
if test "$hash" != "$2"; then
|
||||
echo "hash $1, expected $2, got $hash"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
rm -rf $TEST_ROOT/hash-path
|
||||
mkdir $TEST_ROOT/hash-path
|
||||
echo "Hello World" > $TEST_ROOT/hash-path/hello
|
||||
|
||||
try2 md5 "ea9b55537dd4c7e104515b2ccfaf4100"
|
||||
|
||||
# Execute bit matters.
|
||||
chmod +x $TEST_ROOT/hash-path/hello
|
||||
try2 md5 "20f3ffe011d4cfa7d72bfabef7882836"
|
||||
|
||||
# Mtime and other bits don't.
|
||||
touch -r . $TEST_ROOT/hash-path/hello
|
||||
chmod 744 $TEST_ROOT/hash-path/hello
|
||||
try2 md5 "20f3ffe011d4cfa7d72bfabef7882836"
|
||||
|
||||
# File type (e.g., symlink) does.
|
||||
rm $TEST_ROOT/hash-path/hello
|
||||
ln -s x $TEST_ROOT/hash-path/hello
|
||||
try2 md5 "f78b733a68f5edbdf9413899339eaa4a"
|
||||
|
||||
# Conversion.
|
||||
try3() {
|
||||
h64=$(nix to-base64 --type "$1" "$2")
|
||||
[ "$h64" = "$4" ]
|
||||
sri=$(nix to-sri --type "$1" "$2")
|
||||
[ "$sri" = "$1-$4" ]
|
||||
h32=$(nix-hash --type "$1" --to-base32 "$2")
|
||||
[ "$h32" = "$3" ]
|
||||
h16=$(nix-hash --type "$1" --to-base16 "$h32")
|
||||
[ "$h16" = "$2" ]
|
||||
h16=$(nix to-base16 --type "$1" "$h64")
|
||||
[ "$h16" = "$2" ]
|
||||
h16=$(nix to-base16 "$sri")
|
||||
[ "$h16" = "$2" ]
|
||||
}
|
||||
try3 sha1 "800d59cfcd3c05e900cb4e214be48f6b886a08df" "vw46m23bizj4n8afrc0fj19wrp7mj3c0" "gA1Zz808BekAy04hS+SPa4hqCN8="
|
||||
try3 sha256 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="
|
||||
try3 sha512 "204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445" "12k9jiq29iyqm03swfsgiw5mlqs173qazm3n7daz43infy12pyrcdf30fkk3qwv4yl2ick8yipc2mqnlh48xsvvxl60lbx8vp38yji0" "IEqPxt2oLwoM7XvrjgikFlfBbvRosiioJ5vjMacDwzWW/RXBOxsH+aodO+pXeJygMa2Fx6cd1wNU7GMSOMo0RQ=="
|
||||
26
third_party/nix/tests/import-derivation.nix
vendored
Normal file
26
third_party/nix/tests/import-derivation.nix
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
bar = mkDerivation {
|
||||
name = "bar";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo 'builtins.add 123 456' > $out
|
||||
'';
|
||||
};
|
||||
|
||||
value =
|
||||
# Test that pathExists can check the existence of /nix/store paths
|
||||
assert builtins.pathExists bar;
|
||||
import bar;
|
||||
|
||||
in
|
||||
|
||||
mkDerivation {
|
||||
name = "foo";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo -n FOO${toString value} > $out
|
||||
'';
|
||||
}
|
||||
12
third_party/nix/tests/import-derivation.sh
vendored
Normal file
12
third_party/nix/tests/import-derivation.sh
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
if nix-instantiate --readonly-mode ./import-derivation.nix; then
|
||||
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
outPath=$(nix-build ./import-derivation.nix --no-out-link)
|
||||
|
||||
[ "$(cat $outPath)" = FOO579 ]
|
||||
34
third_party/nix/tests/init.sh
vendored
Normal file
34
third_party/nix/tests/init.sh
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
source common.sh
|
||||
|
||||
test -n "$TEST_ROOT"
|
||||
if test -d "$TEST_ROOT"; then
|
||||
chmod -R u+w "$TEST_ROOT"
|
||||
rm -rf "$TEST_ROOT"
|
||||
fi
|
||||
mkdir "$TEST_ROOT"
|
||||
|
||||
mkdir "$NIX_STORE_DIR"
|
||||
mkdir "$NIX_LOCALSTATE_DIR"
|
||||
mkdir -p "$NIX_LOG_DIR"/drvs
|
||||
mkdir "$NIX_STATE_DIR"
|
||||
mkdir "$NIX_CONF_DIR"
|
||||
|
||||
cat > "$NIX_CONF_DIR"/nix.conf <<EOF
|
||||
build-users-group =
|
||||
keep-derivations = false
|
||||
sandbox = false
|
||||
include nix.conf.extra
|
||||
EOF
|
||||
|
||||
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
||||
fsync-metadata = false
|
||||
!include nix.conf.extra.not-there
|
||||
EOF
|
||||
|
||||
# Initialise the database.
|
||||
nix-store --init
|
||||
|
||||
# Did anything happen?
|
||||
test -e "$NIX_STATE_DIR"/db/db.sqlite
|
||||
|
||||
echo 'Hello World' > ./dummy
|
||||
96
third_party/nix/tests/install-darwin.sh
vendored
Executable file
96
third_party/nix/tests/install-darwin.sh
vendored
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eux
|
||||
|
||||
cleanup() {
|
||||
PLIST="/Library/LaunchDaemons/org.nixos.nix-daemon.plist"
|
||||
if sudo launchctl list | grep -q nix-daemon; then
|
||||
sudo launchctl unload "$PLIST"
|
||||
fi
|
||||
|
||||
if [ -f "$PLIST" ]; then
|
||||
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
||||
fi
|
||||
|
||||
profiles=(/etc/profile /etc/bashrc /etc/zshrc)
|
||||
for profile in "${profiles[@]}"; do
|
||||
if [ -f "${profile}.backup-before-nix" ]; then
|
||||
sudo mv "${profile}.backup-before-nix" "${profile}"
|
||||
fi
|
||||
done
|
||||
|
||||
for file in ~/.bash_profile ~/.bash_login ~/.profile ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin; do
|
||||
if [ -e "$file" ]; then
|
||||
cat "$file" | grep -v nix-profile > "$file.next"
|
||||
mv "$file.next" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
for i in $(seq 1 $(sysctl -n hw.ncpu)); do
|
||||
sudo /usr/bin/dscl . -delete "/Users/nixbld$i" || true
|
||||
done
|
||||
sudo /usr/bin/dscl . -delete "/Groups/nixbld" || true
|
||||
|
||||
sudo rm -rf /etc/nix \
|
||||
/nix \
|
||||
/var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels \
|
||||
"$HOME/.nix-profile" "$HOME/.nix-defexpr" "$HOME/.nix-channels"
|
||||
}
|
||||
|
||||
verify() {
|
||||
set +e
|
||||
output=$(echo "nix-shell -p bash --run 'echo toow | rev'" | bash -l)
|
||||
set -e
|
||||
|
||||
test "$output" = "woot"
|
||||
}
|
||||
|
||||
scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
|
||||
function finish {
|
||||
rm -rf "$scratch"
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
# First setup Nix
|
||||
cleanup
|
||||
curl -o install https://nixos.org/nix/install
|
||||
yes | bash ./install
|
||||
verify
|
||||
|
||||
|
||||
(
|
||||
set +e
|
||||
(
|
||||
echo "cd $(pwd)"
|
||||
echo nix-build ./release.nix -A binaryTarball.x86_64-darwin
|
||||
) | bash -l
|
||||
set -e
|
||||
cp ./result/nix-*.tar.bz2 $scratch/nix.tar.bz2
|
||||
)
|
||||
|
||||
(
|
||||
cd $scratch
|
||||
tar -xf ./nix.tar.bz2
|
||||
|
||||
cd nix-*
|
||||
|
||||
set -eux
|
||||
|
||||
cleanup
|
||||
|
||||
yes | ./install
|
||||
verify
|
||||
cleanup
|
||||
|
||||
echo -n "" | ./install
|
||||
verify
|
||||
cleanup
|
||||
|
||||
sudo mkdir -p /nix/store
|
||||
sudo touch /nix/store/.silly-hint
|
||||
echo -n "" | ALLOW_PREEXISTING_INSTALLATION=true ./install
|
||||
verify
|
||||
test -e /nix/store/.silly-hint
|
||||
|
||||
cleanup
|
||||
)
|
||||
70
third_party/nix/tests/lang.sh
vendored
Normal file
70
third_party/nix/tests/lang.sh
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
source common.sh
|
||||
|
||||
export TEST_VAR=foo # for eval-okay-getenv.nix
|
||||
|
||||
nix-instantiate --eval -E 'builtins.trace "Hello" 123' 2>&1 | grep -q Hello
|
||||
(! nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" 123' 2>&1 | grep -q Hello)
|
||||
nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" (throw "Foo")' 2>&1 | grep -q Hello
|
||||
|
||||
set +x
|
||||
|
||||
fail=0
|
||||
|
||||
for i in lang/parse-fail-*.nix; do
|
||||
echo "parsing $i (should fail)";
|
||||
i=$(basename $i .nix)
|
||||
if nix-instantiate --parse - < lang/$i.nix; then
|
||||
echo "FAIL: $i shouldn't parse"
|
||||
fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
for i in lang/parse-okay-*.nix; do
|
||||
echo "parsing $i (should succeed)";
|
||||
i=$(basename $i .nix)
|
||||
if ! nix-instantiate --parse - < lang/$i.nix > lang/$i.out; then
|
||||
echo "FAIL: $i should parse"
|
||||
fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
for i in lang/eval-fail-*.nix; do
|
||||
echo "evaluating $i (should fail)";
|
||||
i=$(basename $i .nix)
|
||||
if nix-instantiate --eval lang/$i.nix; then
|
||||
echo "FAIL: $i shouldn't evaluate"
|
||||
fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
for i in lang/eval-okay-*.nix; do
|
||||
echo "evaluating $i (should succeed)";
|
||||
i=$(basename $i .nix)
|
||||
|
||||
if test -e lang/$i.exp; then
|
||||
flags=
|
||||
if test -e lang/$i.flags; then
|
||||
flags=$(cat lang/$i.flags)
|
||||
fi
|
||||
if ! NIX_PATH=lang/dir3:lang/dir4 nix-instantiate $flags --eval --strict lang/$i.nix > lang/$i.out; then
|
||||
echo "FAIL: $i should evaluate"
|
||||
fail=1
|
||||
elif ! diff lang/$i.out lang/$i.exp; then
|
||||
echo "FAIL: evaluation result of $i not as expected"
|
||||
fail=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -e lang/$i.exp.xml; then
|
||||
if ! nix-instantiate --eval --xml --no-location --strict \
|
||||
lang/$i.nix > lang/$i.out.xml; then
|
||||
echo "FAIL: $i should evaluate"
|
||||
fail=1
|
||||
elif ! cmp -s lang/$i.out.xml lang/$i.exp.xml; then
|
||||
echo "FAIL: XML evaluation result of $i not as expected"
|
||||
fail=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit $fail
|
||||
BIN
third_party/nix/tests/lang/binary-data
vendored
Normal file
BIN
third_party/nix/tests/lang/binary-data
vendored
Normal file
Binary file not shown.
1
third_party/nix/tests/lang/data
vendored
Normal file
1
third_party/nix/tests/lang/data
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
foo
|
||||
1
third_party/nix/tests/lang/dir1/a.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir1/a.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"a"
|
||||
1
third_party/nix/tests/lang/dir2/a.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir2/a.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"X"
|
||||
1
third_party/nix/tests/lang/dir2/b.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir2/b.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"b"
|
||||
1
third_party/nix/tests/lang/dir3/a.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir3/a.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"X"
|
||||
1
third_party/nix/tests/lang/dir3/b.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir3/b.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"X"
|
||||
1
third_party/nix/tests/lang/dir3/c.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir3/c.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"c"
|
||||
1
third_party/nix/tests/lang/dir4/a.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir4/a.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"X"
|
||||
1
third_party/nix/tests/lang/dir4/c.nix
vendored
Normal file
1
third_party/nix/tests/lang/dir4/c.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"X"
|
||||
1
third_party/nix/tests/lang/eval-fail-abort.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-abort.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
if true then abort "this should fail" else 1
|
||||
4
third_party/nix/tests/lang/eval-fail-antiquoted-path.nix
vendored
Normal file
4
third_party/nix/tests/lang/eval-fail-antiquoted-path.nix
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# This must fail to evaluate, since ./fnord doesn't exist. If it did
|
||||
# exist, it would produce "/nix/store/<hash>-fnord/xyzzy" (with an
|
||||
# appropriate context).
|
||||
"${./fnord}/xyzzy"
|
||||
5
third_party/nix/tests/lang/eval-fail-assert.nix
vendored
Normal file
5
third_party/nix/tests/lang/eval-fail-assert.nix
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
x = arg: assert arg == "y"; 123;
|
||||
|
||||
body = x "x";
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-fail-bad-antiquote-1.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-bad-antiquote-1.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"${x: x}"
|
||||
1
third_party/nix/tests/lang/eval-fail-bad-antiquote-2.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-bad-antiquote-2.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"${./fnord}"
|
||||
1
third_party/nix/tests/lang/eval-fail-bad-antiquote-3.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-bad-antiquote-3.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
''${x: x}''
|
||||
5
third_party/nix/tests/lang/eval-fail-blackhole.nix
vendored
Normal file
5
third_party/nix/tests/lang/eval-fail-blackhole.nix
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
body = x;
|
||||
x = y;
|
||||
y = x;
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-fail-deepseq.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-deepseq.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
builtins.deepSeq { x = abort "foo"; } 456
|
||||
5
third_party/nix/tests/lang/eval-fail-hashfile-missing.nix
vendored
Normal file
5
third_party/nix/tests/lang/eval-fail-hashfile-missing.nix
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let
|
||||
paths = [ ./this-file-is-definitely-not-there-7392097 "/and/neither/is/this/37293620" ];
|
||||
in
|
||||
toString (builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"]))
|
||||
|
||||
1
third_party/nix/tests/lang/eval-fail-missing-arg.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-missing-arg.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
({x, y, z}: x + y + z) {x = "foo"; z = "bar";}
|
||||
6
third_party/nix/tests/lang/eval-fail-path-slash.nix
vendored
Normal file
6
third_party/nix/tests/lang/eval-fail-path-slash.nix
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Trailing slashes in paths are not allowed.
|
||||
# This restriction could be lifted sometime,
|
||||
# for example if we make '/' a path concatenation operator.
|
||||
# See https://github.com/NixOS/nix/issues/1138
|
||||
# and https://nixos.org/nix-dev/2016-June/020829.html
|
||||
/nix/store/
|
||||
5
third_party/nix/tests/lang/eval-fail-remove.nix
vendored
Normal file
5
third_party/nix/tests/lang/eval-fail-remove.nix
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
attrs = {x = 123; y = 456;};
|
||||
|
||||
body = (removeAttrs attrs ["x"]).x;
|
||||
}
|
||||
10
third_party/nix/tests/lang/eval-fail-scope-5.nix
vendored
Normal file
10
third_party/nix/tests/lang/eval-fail-scope-5.nix
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let {
|
||||
|
||||
x = "a";
|
||||
y = "b";
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
|
||||
body = f {};
|
||||
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-fail-seq.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-seq.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
builtins.seq (abort "foo") 2
|
||||
1
third_party/nix/tests/lang/eval-fail-substring.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-substring.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
builtins.substring (builtins.sub 0 1) 1 "x"
|
||||
1
third_party/nix/tests/lang/eval-fail-to-path.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-to-path.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
builtins.toPath "foo/bar"
|
||||
1
third_party/nix/tests/lang/eval-fail-undeclared-arg.nix
vendored
Normal file
1
third_party/nix/tests/lang/eval-fail-undeclared-arg.nix
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";}
|
||||
1
third_party/nix/tests/lang/eval-okay-any-all.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-any-all.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
[ false false true true true true false true ]
|
||||
11
third_party/nix/tests/lang/eval-okay-any-all.nix
vendored
Normal file
11
third_party/nix/tests/lang/eval-okay-any-all.nix
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
with builtins;
|
||||
|
||||
[ (any (x: x == 1) [])
|
||||
(any (x: x == 1) [2 3 4])
|
||||
(any (x: x == 1) [1 2 3 4])
|
||||
(any (x: x == 1) [4 3 2 1])
|
||||
(all (x: x == 1) [])
|
||||
(all (x: x == 1) [1])
|
||||
(all (x: x == 1) [1 2 3])
|
||||
(all (x: x == 1) [1 1 1])
|
||||
]
|
||||
1
third_party/nix/tests/lang/eval-okay-arithmetic.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-arithmetic.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
2216
|
||||
59
third_party/nix/tests/lang/eval-okay-arithmetic.nix
vendored
Normal file
59
third_party/nix/tests/lang/eval-okay-arithmetic.nix
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let {
|
||||
|
||||
/* Supposedly tail recursive version:
|
||||
|
||||
range_ = accum: first: last:
|
||||
if first == last then ([first] ++ accum)
|
||||
else range_ ([first] ++ accum) (builtins.add first 1) last;
|
||||
|
||||
range = range_ [];
|
||||
*/
|
||||
|
||||
x = 12;
|
||||
|
||||
err = abort "urgh";
|
||||
|
||||
body = sum
|
||||
[ (sum (range 1 50))
|
||||
(123 + 456)
|
||||
(0 + -10 + -(-11) + -x)
|
||||
(10 - 7 - -2)
|
||||
(10 - (6 - -1))
|
||||
(10 - 1 + 2)
|
||||
(3 * 4 * 5)
|
||||
(56088 / 123 / 2)
|
||||
(3 + 4 * const 5 0 - 6 / id 2)
|
||||
|
||||
(builtins.bitAnd 12 10) # 0b1100 & 0b1010 = 8
|
||||
(builtins.bitOr 12 10) # 0b1100 | 0b1010 = 14
|
||||
(builtins.bitXor 12 10) # 0b1100 ^ 0b1010 = 6
|
||||
|
||||
(if 3 < 7 then 1 else err)
|
||||
(if 7 < 3 then err else 1)
|
||||
(if 3 < 3 then err else 1)
|
||||
|
||||
(if 3 <= 7 then 1 else err)
|
||||
(if 7 <= 3 then err else 1)
|
||||
(if 3 <= 3 then 1 else err)
|
||||
|
||||
(if 3 > 7 then err else 1)
|
||||
(if 7 > 3 then 1 else err)
|
||||
(if 3 > 3 then err else 1)
|
||||
|
||||
(if 3 >= 7 then err else 1)
|
||||
(if 7 >= 3 then 1 else err)
|
||||
(if 3 >= 3 then 1 else err)
|
||||
|
||||
(if 2 > 1 == 1 < 2 then 1 else err)
|
||||
(if 1 + 2 * 3 >= 7 then 1 else err)
|
||||
(if 1 + 2 * 3 < 7 then err else 1)
|
||||
|
||||
# Not integer, but so what.
|
||||
(if "aa" < "ab" then 1 else err)
|
||||
(if "aa" < "aa" then err else 1)
|
||||
(if "foo" < "foobar" then 1 else err)
|
||||
];
|
||||
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-okay-attrnames.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrnames.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"newxfoonewxy"
|
||||
11
third_party/nix/tests/lang/eval-okay-attrnames.nix
vendored
Normal file
11
third_party/nix/tests/lang/eval-okay-attrnames.nix
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
|
||||
attrs = {y = "y"; x = "x"; foo = "foo";} // rec {x = "newx"; bar = x;};
|
||||
|
||||
names = builtins.attrNames attrs;
|
||||
|
||||
values = map (name: builtins.getAttr name attrs) names;
|
||||
|
||||
in assert values == builtins.attrValues attrs; concat values
|
||||
1
third_party/nix/tests/lang/eval-okay-attrs.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrs.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
987
|
||||
5
third_party/nix/tests/lang/eval-okay-attrs.nix
vendored
Normal file
5
third_party/nix/tests/lang/eval-okay-attrs.nix
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let {
|
||||
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
||||
|
||||
body = if as ? a then as.a else assert as ? z; as.z;
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-okay-attrs2.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrs2.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
987
|
||||
10
third_party/nix/tests/lang/eval-okay-attrs2.nix
vendored
Normal file
10
third_party/nix/tests/lang/eval-okay-attrs2.nix
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let {
|
||||
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
||||
|
||||
A = "a";
|
||||
Z = "z";
|
||||
|
||||
body = if builtins.hasAttr A as
|
||||
then builtins.getAttr A as
|
||||
else assert builtins.hasAttr Z as; builtins.getAttr Z as;
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-okay-attrs3.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrs3.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"foo 22 80 itchyxac"
|
||||
22
third_party/nix/tests/lang/eval-okay-attrs3.nix
vendored
Normal file
22
third_party/nix/tests/lang/eval-okay-attrs3.nix
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
let
|
||||
|
||||
config =
|
||||
{
|
||||
services.sshd.enable = true;
|
||||
services.sshd.port = 22;
|
||||
services.httpd.port = 80;
|
||||
hostName = "itchy";
|
||||
a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z = "x";
|
||||
foo = {
|
||||
a = "a";
|
||||
b.c = "c";
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
if config.services.sshd.enable
|
||||
then "foo ${toString config.services.sshd.port} ${toString config.services.httpd.port} ${config.hostName}"
|
||||
+ "${config.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z}"
|
||||
+ "${config.foo.a}"
|
||||
+ "${config.foo.b.c}"
|
||||
else "bar"
|
||||
1
third_party/nix/tests/lang/eval-okay-attrs4.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrs4.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
[ true false true false false true false false ]
|
||||
7
third_party/nix/tests/lang/eval-okay-attrs4.nix
vendored
Normal file
7
third_party/nix/tests/lang/eval-okay-attrs4.nix
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let
|
||||
|
||||
as = { x.y.z = 123; a.b.c = 456; };
|
||||
|
||||
bs = null;
|
||||
|
||||
in [ (as ? x) (as ? y) (as ? x.y.z) (as ? x.y.z.a) (as ? x.y.a) (as ? a.b.c) (bs ? x) (bs ? x.y.z) ]
|
||||
1
third_party/nix/tests/lang/eval-okay-attrs5.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrs5.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
[ 123 "foo" 456 456 "foo" "xyzzy" "xyzzy" true ]
|
||||
21
third_party/nix/tests/lang/eval-okay-attrs5.nix
vendored
Normal file
21
third_party/nix/tests/lang/eval-okay-attrs5.nix
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
|
||||
as = { x.y.z = 123; a.b.c = 456; };
|
||||
|
||||
bs = { f-o-o.bar = "foo"; };
|
||||
|
||||
or = x: y: x || y;
|
||||
|
||||
in
|
||||
[ as.x.y.z
|
||||
as.foo or "foo"
|
||||
as.x.y.bla or as.a.b.c
|
||||
as.a.b.c or as.x.y.z
|
||||
as.x.y.bla or bs.f-o-o.bar or "xyzzy"
|
||||
as.x.y.bla or bs.bar.foo or "xyzzy"
|
||||
(123).bla or null.foo or "xyzzy"
|
||||
# Backwards compatibility test.
|
||||
(fold or [] [true false false])
|
||||
]
|
||||
1
third_party/nix/tests/lang/eval-okay-attrs6.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-attrs6.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ __overrides = { bar = "qux"; }; bar = "qux"; foo = "bar"; }
|
||||
4
third_party/nix/tests/lang/eval-okay-attrs6.nix
vendored
Normal file
4
third_party/nix/tests/lang/eval-okay-attrs6.nix
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
rec {
|
||||
"${"foo"}" = "bar";
|
||||
__overrides = { bar = "qux"; };
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-okay-autoargs.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-autoargs.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"xyzzy!xyzzy!foobar"
|
||||
1
third_party/nix/tests/lang/eval-okay-autoargs.flags
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-autoargs.flags
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
--arg lib import(lang/lib.nix) --argstr xyzzy xyzzy! -A result
|
||||
15
third_party/nix/tests/lang/eval-okay-autoargs.nix
vendored
Normal file
15
third_party/nix/tests/lang/eval-okay-autoargs.nix
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
let
|
||||
|
||||
foobar = "foobar";
|
||||
|
||||
in
|
||||
|
||||
{ xyzzy2 ? xyzzy # mutually recursive args
|
||||
, xyzzy ? "blaat" # will be overridden by --argstr
|
||||
, fb ? foobar
|
||||
, lib # will be set by --arg
|
||||
}:
|
||||
|
||||
{
|
||||
result = lib.concat [xyzzy xyzzy2 fb];
|
||||
}
|
||||
1
third_party/nix/tests/lang/eval-okay-backslash-newline-1.exp
vendored
Normal file
1
third_party/nix/tests/lang/eval-okay-backslash-newline-1.exp
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"a\nb"
|
||||
2
third_party/nix/tests/lang/eval-okay-backslash-newline-1.nix
vendored
Normal file
2
third_party/nix/tests/lang/eval-okay-backslash-newline-1.nix
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"a\
|
||||
b"
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue