aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-01-21 16:27:53 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-01-21 22:56:04 +0100
commit9f4d8c6170517c9452e25dc29c56a6fbb43d40a1 (patch)
tree25295dae9cd204f603b41ae59bc32cd9cb0ce88e /tests
parent1bf9eb21b75f0d93d9c1633ea2e6fdf840047e79 (diff)
Pluggable fetchers
Flakes are now fetched using an extensible mechanism. Also lots of other flake cleanups.
Diffstat (limited to 'tests')
-rw-r--r--tests/fetchGit.sh5
-rw-r--r--tests/flakes.sh48
2 files changed, 28 insertions, 25 deletions
diff --git a/tests/fetchGit.sh b/tests/fetchGit.sh
index 25333e477..ac0d78f12 100644
--- a/tests/fetchGit.sh
+++ b/tests/fetchGit.sh
@@ -71,6 +71,7 @@ echo bar > $repo/dir2/bar
git -C $repo add dir1/foo
git -C $repo rm hello
+unset _NIX_FORCE_HTTP
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit $repo).outPath")
[ ! -e $path2/hello ]
[ ! -e $path2/bar ]
@@ -107,9 +108,9 @@ path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath"
git -C $repo checkout $rev2 -b dev
echo dev > $repo/hello
-# File URI uses 'master' unless specified otherwise
+# File URI uses dirty tree unless specified otherwise
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
-[[ $path = $path2 ]]
+[ $(cat $path2/hello) = dev ]
# Using local path with branch other than 'master' should work when clean or dirty
path3=$(nix eval --impure --raw --expr "(builtins.fetchGit $repo).outPath")
diff --git a/tests/flakes.sh b/tests/flakes.sh
index 910d39f97..334f750fb 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -5,10 +5,8 @@ if [[ -z $(type -p git) ]]; then
exit 99
fi
-export _NIX_FORCE_HTTP=1
-
clearStore
-rm -rf $TEST_HOME/.cache
+rm -rf $TEST_HOME/.cache $TEST_HOME/.config
registry=$TEST_ROOT/registry.json
@@ -91,20 +89,20 @@ git -C $nonFlakeDir commit -m 'Initial'
cat > $registry <<EOF
{
"flakes": {
- "flake1": {
- "url": "file://$flake1Dir"
+ "flake:flake1": {
+ "url": "git+file://$flake1Dir"
},
- "flake2": {
- "url": "file://$flake2Dir"
+ "flake:flake2": {
+ "url": "git+file://$flake2Dir"
},
- "flake3": {
- "url": "file://$flake3Dir"
+ "flake:flake3": {
+ "url": "git+file://$flake3Dir"
},
- "flake4": {
- "url": "flake3"
+ "flake:flake4": {
+ "url": "flake:flake3"
},
- "nixpkgs": {
- "url": "flake1"
+ "flake:nixpkgs": {
+ "url": "flake:flake1"
}
},
"version": 1
@@ -137,10 +135,10 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake1
[[ -e $TEST_ROOT/result/hello ]]
nix build -o $TEST_ROOT/result --flake-registry $registry $flake1Dir
-nix build -o $TEST_ROOT/result --flake-registry $registry file://$flake1Dir
+nix build -o $TEST_ROOT/result --flake-registry $registry git+file://$flake1Dir
-# CHeck that store symlinks inside a flake are not interpreted as flakes.
-nix build -o $flake1Dir/result --flake-registry $registry file://$flake1Dir
+# Check that store symlinks inside a flake are not interpreted as flakes.
+nix build -o $flake1Dir/result --flake-registry $registry git+file://$flake1Dir
nix path-info $flake1Dir/result
# Building a flake with an unlocked dependency should fail in pure mode.
@@ -152,6 +150,7 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake2#bar --impure
# Test automatic lock file generation.
nix build -o $TEST_ROOT/result --flake-registry $registry $flake2Dir#bar
[[ -e $flake2Dir/flake.lock ]]
+git -C $flake2Dir add flake.lock
git -C $flake2Dir commit flake.lock -m 'Add flake.lock'
# Rerunning the build should not change the lockfile.
@@ -170,10 +169,11 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake2#bar
# Or without a registry.
# FIXME: shouldn't need '--flake-registry /no-registry'?
-nix build -o $TEST_ROOT/result --flake-registry /no-registry file://$flake2Dir#bar --tarball-ttl 0
+nix build -o $TEST_ROOT/result --flake-registry /no-registry git+file://$flake2Dir#bar --tarball-ttl 0
# Test whether indirect dependencies work.
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir#xyzzy
+git -C $flake3Dir add flake.lock
# Add dependency to flake3.
rm $flake3Dir/flake.nix
@@ -196,9 +196,10 @@ git -C $flake3Dir commit -m 'Update flake.nix'
# Check whether `nix build` works with an incomplete lockfile
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir#"sth sth"
+nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir#"sth%20sth"
# Check whether it saved the lockfile
-[[ ! (-z $(git -C $flake3Dir diff master)) ]]
+(! [[ -z $(git -C $flake3Dir diff master) ]])
git -C $flake3Dir add flake.lock
@@ -217,12 +218,12 @@ mv $registry.tmp $registry
# Test whether flakes are registered as GC roots for offline use.
# FIXME: use tarballs rather than git.
rm -rf $TEST_HOME/.cache
-nix build -o $TEST_ROOT/result --flake-registry file://$registry file://$flake2Dir#bar
+_NIX_FORCE_HTTP=1 nix build -o $TEST_ROOT/result --flake-registry file://$registry git+file://$flake2Dir#bar
mv $flake1Dir $flake1Dir.tmp
mv $flake2Dir $flake2Dir.tmp
nix-store --gc
-nix build -o $TEST_ROOT/result --flake-registry file://$registry file://$flake2Dir#bar
-nix build -o $TEST_ROOT/result --flake-registry file://$registry file://$flake2Dir#bar --tarball-ttl 0
+_NIX_FORCE_HTTP=1 nix build -o $TEST_ROOT/result --flake-registry file://$registry git+file://$flake2Dir#bar
+_NIX_FORCE_HTTP=1 nix build -o $TEST_ROOT/result --flake-registry file://$registry git+file://$flake2Dir#bar --tarball-ttl 0
mv $flake1Dir.tmp $flake1Dir
mv $flake2Dir.tmp $flake2Dir
@@ -237,7 +238,7 @@ cat > $flake3Dir/flake.nix <<EOF
flake1 = {};
flake2 = {};
nonFlake = {
- url = "$nonFlakeDir";
+ url = git+file://$nonFlakeDir;
flake = false;
};
};
@@ -348,7 +349,8 @@ git -C $flake7Dir add flake.nix
nix flake --flake-registry $registry check $flake7Dir
rm -rf $TEST_ROOT/flake1-v2
-nix flake clone --flake-registry $registry flake1 $TEST_ROOT/flake1-v2
+nix flake clone --flake-registry $registry flake1 --dest $TEST_ROOT/flake1-v2
+[ -e $TEST_ROOT/flake1-v2/flake.nix ]
# More 'nix flake check' tests.
cat > $flake3Dir/flake.nix <<EOF