diff --git a/README.md b/README.md index bb56f63..28b3e08 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,9 @@ Here is a short example: outputs = { nixpkgs, ... }: { colmena = { meta = { - inherit nixpkgs; + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + }; }; # Also see the non-Flakes hive.nix example above. diff --git a/src/nix/eval.nix b/src/nix/eval.nix index 22798d7..4df2511 100644 --- a/src/nix/eval.nix +++ b/src/nix/eval.nix @@ -291,15 +291,32 @@ let }; in mergedHive // meta; - mkNixpkgs = configName: pkgConf: + mkNixpkgs = configName: pkgConf: let + uninitializedError = typ: '' + Passing ${typ} is no longer accepted with Flakes. Please initialize Nixpkgs like the following: + + { + # ... + outputs = { nixpkgs, ... }: { + colmena = { + meta = { + nixpkgs = import nixpkgs { + system = "${currentSystem}"; + }; + }; + }; + }; + } + ''; + in if typeOf pkgConf == "path" then + if hermetic then throw (uninitializedError "a path to Nixpkgs") # The referenced file might return an initialized Nixpkgs attribute set directly - mkNixpkgs configName (import pkgConf) + else mkNixpkgs configName (import pkgConf) else if typeOf pkgConf == "lambda" then pkgConf {} else if typeOf pkgConf == "set" then - # FIXME: Allow configuring `system` - if pkgConf ? outputs then mkNixpkgs configName pkgConf.outputs.legacyPackages.${currentSystem}.path + if pkgConf ? outputs then throw (uninitializedError "an uninitialized Nixpkgs input") else pkgConf else throw '' ${configName} must be one of: diff --git a/src/nix/tests/simple-flake/flake.nix b/src/nix/tests/simple-flake/flake.nix index 5f888f9..91bdc34 100644 --- a/src/nix/tests/simple-flake/flake.nix +++ b/src/nix/tests/simple-flake/flake.nix @@ -5,7 +5,9 @@ outputs = { nixpkgs, ... }: { colmena = { meta = { - inherit nixpkgs; + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + }; }; host-a = { name, nodes, pkgs, ... }: {