aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-10-15 17:52:10 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-10-15 18:16:29 +0200
commit7d38060a0da2698052e84a0cfee422d409a38187 (patch)
treeb81347894cd8c8468e24d2262f4e226a48598575 /tests
parent0bc8f1669d542ef65fbfa80ea3728f4dd36d63f2 (diff)
Support non-x86_64-linux system types in flakes
A command like $ nix run nixpkgs#hello will now build the attribute 'packages.${system}.hello' rather than 'packages.hello'. Note that this does mean that the flake needs to export an attribute for every system type it supports, and you can't build on unsupported systems. So 'packages' typically looks like this: packages = nixpkgs.lib.genAttrs ["x86_64-linux" "i686-linux"] (system: { hello = ...; }); The 'checks', 'defaultPackage', 'devShell', 'apps' and 'defaultApp' outputs similarly are now attrsets that map system types to derivations/apps. 'nix flake check' checks that the derivations for all platforms evaluate correctly, but only builds the derivations in 'checks.${system}'. Fixes #2861. (That issue also talks about access to ~/.config/nixpkgs and --arg, but I think it's reasonable to say that flakes shouldn't support those.) The alternative to attribute selection is to pass the system type as an argument to the flake's 'outputs' function, e.g. 'outputs = { self, nixpkgs, system }: ...'. However, that approach would be at odds with hermetic evaluation and make it impossible to enumerate the packages provided by a flake.
Diffstat (limited to 'tests')
-rw-r--r--tests/flakes.sh24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/flakes.sh b/tests/flakes.sh
index c5e19826c..73f9d2685 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -34,8 +34,8 @@ cat > $flake1Dir/flake.nix <<EOF
description = "Bla bla";
outputs = inputs: rec {
- packages.foo = import ./simple.nix;
- defaultPackage = packages.foo;
+ packages.$system.foo = import ./simple.nix;
+ defaultPackage.$system = packages.$system.foo;
};
}
EOF
@@ -51,7 +51,7 @@ cat > $flake2Dir/flake.nix <<EOF
description = "Fnord";
outputs = { self, flake1 }: rec {
- packages.bar = flake1.packages.foo;
+ packages.$system.bar = flake1.packages.$system.foo;
};
}
EOF
@@ -66,10 +66,10 @@ cat > $flake3Dir/flake.nix <<EOF
description = "Fnord";
outputs = { self, flake2 }: rec {
- packages.xyzzy = flake2.packages.bar;
+ packages.$system.xyzzy = flake2.packages.$system.bar;
checks = {
- xyzzy = packages.xyzzy;
+ xyzzy = packages.$system.xyzzy;
};
};
}
@@ -182,8 +182,8 @@ cat > $flake3Dir/flake.nix <<EOF
description = "Fnord";
outputs = { self, flake1, flake2 }: rec {
- packages.xyzzy = flake2.packages.bar;
- packages."sth sth" = flake1.packages.foo;
+ packages.$system.xyzzy = flake2.packages.$system.bar;
+ packages.$system."sth sth" = flake1.packages.$system.foo;
};
}
EOF
@@ -242,9 +242,9 @@ cat > $flake3Dir/flake.nix <<EOF
description = "Fnord";
outputs = inputs: rec {
- packages.xyzzy = inputs.flake2.packages.bar;
- packages.sth = inputs.flake1.packages.foo;
- packages.fnord =
+ packages.$system.xyzzy = inputs.flake2.packages.$system.bar;
+ packages.$system.sth = inputs.flake1.packages.$system.foo;
+ packages.$system.fnord =
with import ./config.nix;
mkDerivation {
inherit system;
@@ -307,8 +307,8 @@ cat > $flake3Dir/flake.nix <<EOF
description = "Fnord";
outputs = { self, flake1, flake2, nonFlake }: rec {
- packages.sth = flake1.packages.foo;
- packages.fnord =
+ packages.$system.sth = flake1.packages.$system.foo;
+ packages.$system.fnord =
with import ./config.nix;
mkDerivation {
inherit system;