aboutsummaryrefslogtreecommitdiff
path: root/src/nix/command.hh
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 /src/nix/command.hh
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 'src/nix/command.hh')
-rw-r--r--src/nix/command.hh17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 802dd9828..93f324071 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -64,22 +64,9 @@ struct SourceExprCommand : virtual Args, EvalCommand, MixFlakeOptions
std::shared_ptr<Installable> parseInstallable(
ref<Store> store, const std::string & installable);
- virtual Strings getDefaultFlakeAttrPaths()
- {
- return {"defaultPackage"};
- }
+ virtual Strings getDefaultFlakeAttrPaths();
- virtual Strings getDefaultFlakeAttrPathPrefixes()
- {
- return {
- // As a convenience, look for the attribute in
- // 'outputs.packages'.
- "packages.",
- // As a temporary hack until Nixpkgs is properly converted
- // to provide a clean 'packages' set, look in 'legacyPackages'.
- "legacyPackages."
- };
- }
+ virtual Strings getDefaultFlakeAttrPathPrefixes();
};
enum RealiseMode { Build, NoBuild, DryRun };