aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-02-11 18:11:08 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-02-22 11:47:41 +0100
commit162fbe31ffe4c2b2d7648e5df2d5a0c9b4a44996 (patch)
tree583872a69ddbd873b4c08dcd61ab68f9e2a0443c /tests
parentcaf51729450d4c57d48ddbef8e855e9bf65f8792 (diff)
Replace defaultBla.$system with bla.$system.default
This also simplifies some InstallableFlake logic and fixes 'nix bundle' parsing its installable twice. Fixes #5532.
Diffstat (limited to 'tests')
-rw-r--r--tests/flake-bundler.sh26
-rw-r--r--tests/flake-local-settings.sh2
-rw-r--r--tests/flake-searching.sh6
-rw-r--r--tests/flakes.sh36
4 files changed, 38 insertions, 32 deletions
diff --git a/tests/flake-bundler.sh b/tests/flake-bundler.sh
index 699920f60..9496b8f92 100644
--- a/tests/flake-bundler.sh
+++ b/tests/flake-bundler.sh
@@ -10,26 +10,28 @@ cd $TEST_HOME
cat <<EOF > flake.nix
{
outputs = {self}: {
- bundlers.$system.simple = drv:
+ bundlers.$system = rec {
+ simple = drv:
if drv?type && drv.type == "derivation"
then drv
- else self.defaultPackage.$system;
- defaultBundler.$system = self.bundlers.$system.simple;
- defaultPackage.$system = import ./simple.nix;
- defaultApp.$system = {
- type = "app";
- program = "\${import ./simple.nix}/hello";
- };
+ else self.packages.$system.default;
+ default = simple;
+ };
+ packages.$system.default = import ./simple.nix;
+ apps.$system.default = {
+ type = "app";
+ program = "\${import ./simple.nix}/hello";
+ };
};
}
EOF
nix build .#
nix bundle --bundler .# .#
-nix bundle --bundler .#defaultBundler.$system .#defaultPackage.$system
-nix bundle --bundler .#bundlers.$system.simple .#defaultPackage.$system
+nix bundle --bundler .#bundlers.$system.default .#packages.$system.default
+nix bundle --bundler .#bundlers.$system.simple .#packages.$system.default
-nix bundle --bundler .#defaultBundler.$system .#defaultApp.$system
-nix bundle --bundler .#bundlers.$system.simple .#defaultApp.$system
+nix bundle --bundler .#bundlers.$system.default .#apps.$system.default
+nix bundle --bundler .#bundlers.$system.simple .#apps.$system.default
clearStore
diff --git a/tests/flake-local-settings.sh b/tests/flake-local-settings.sh
index 7765fe379..e92c16f87 100644
--- a/tests/flake-local-settings.sh
+++ b/tests/flake-local-settings.sh
@@ -21,7 +21,7 @@ cat <<EOF > flake.nix
nixConfig.allow-dirty = false; # See #5621
outputs = a: {
- defaultPackage.$system = import ./simple.nix;
+ packages.$system.default = import ./simple.nix;
};
}
EOF
diff --git a/tests/flake-searching.sh b/tests/flake-searching.sh
index bc55f2bdc..db241f6d2 100644
--- a/tests/flake-searching.sh
+++ b/tests/flake-searching.sh
@@ -15,8 +15,10 @@ cat <<EOF > flake.nix
{
inputs.foo.url = "$PWD/foo";
outputs = a: {
- defaultPackage.$system = import ./simple.nix;
- packages.$system.test = import ./simple.nix;
+ packages.$system = rec {
+ test = import ./simple.nix;
+ default = test;
+ };
};
}
EOF
diff --git a/tests/flakes.sh b/tests/flakes.sh
index db178967f..ea629ae70 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -41,8 +41,10 @@ cat > $flake1Dir/flake.nix <<EOF
description = "Bla bla";
outputs = inputs: rec {
- packages.$system.foo = import ./simple.nix;
- defaultPackage.$system = packages.$system.foo;
+ packages.$system = rec {
+ foo = import ./simple.nix;
+ default = foo;
+ };
# To test "nix flake init".
legacyPackages.x86_64-linux.hello = import ./simple.nix;
@@ -128,7 +130,7 @@ hash2=$(nix flake metadata flake1 --json --refresh | jq -r .revision)
nix build -o $TEST_ROOT/result flake1#foo
[[ -e $TEST_ROOT/result/hello ]]
-# Test defaultPackage.
+# Test packages.default.
nix build -o $TEST_ROOT/result flake1
[[ -e $TEST_ROOT/result/hello ]]
@@ -140,11 +142,11 @@ nix build -o $flake1Dir/result git+file://$flake1Dir
nix path-info $flake1Dir/result
# 'getFlake' on a mutable flakeref should fail in pure mode, but succeed in impure mode.
-(! nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").defaultPackage.$system")
-nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").defaultPackage.$system" --impure
+(! nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default")
+nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default" --impure
# 'getFlake' on an immutable flakeref should succeed even in pure mode.
-nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").defaultPackage.$system"
+nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").packages.$system.default"
# Building a flake with an unlocked dependency should fail in pure mode.
(! nix build -o $TEST_ROOT/result flake2#bar --no-registries)
@@ -370,13 +372,13 @@ cat > $templatesDir/flake.nix <<EOF
description = "Some templates";
outputs = { self }: {
- templates = {
+ templates = rec {
trivial = {
path = ./trivial;
description = "A trivial flake";
};
+ default = trivial;
};
- defaultTemplate = self.templates.trivial;
};
}
EOF
@@ -388,8 +390,10 @@ cat > $templatesDir/trivial/flake.nix <<EOF
description = "A flake for building Hello World";
outputs = { self, nixpkgs }: {
- packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
- defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
+ packages.x86_64-linux = rec {
+ hello = nixpkgs.legacyPackages.x86_64-linux.hello;
+ default = hello;
+ };
};
}
EOF
@@ -496,17 +500,15 @@ EOF
cat > $flake3Dir/flake.nix <<EOF
{
outputs = { flake1, self }: {
- defaultPackage = {
- system-1 = "foo";
- system-2 = "bar";
- };
+ packages.system-1.default = "foo";
+ packages.system-2.default = "bar";
};
}
EOF
checkRes=$(nix flake check --keep-going $flake3Dir 2>&1 && fail "nix flake check should have failed" || true)
-echo "$checkRes" | grep -q "defaultPackage.system-1"
-echo "$checkRes" | grep -q "defaultPackage.system-2"
+echo "$checkRes" | grep -q "packages.system-1.default"
+echo "$checkRes" | grep -q "packages.system-2.default"
# Test 'follows' inputs.
cat > $flake3Dir/flake.nix <<EOF
@@ -591,7 +593,7 @@ mkdir $flake5Dir
cat > $flake5Dir/flake.nix <<EOF
{
outputs = { self, flake1 }: {
- defaultPackage.$system = flake1.defaultPackage.$system;
+ packages.$system.default = flake1.packages.$system.default;
expr = assert builtins.pathExists ./flake.lock; 123;
};
}