diff options
| author | Michael Hoang <enzime@users.noreply.github.com> | 2022-02-04 21:32:40 +1100 |
|---|---|---|
| committer | Michael Hoang <enzime@users.noreply.github.com> | 2022-02-04 21:32:40 +1100 |
| commit | 5528b366981dab354f7ec7299c26b8c9303cdf06 (patch) | |
| tree | 9e55b285cc8ad832506ef8bf73b24e4bba505faa /eval-config.nix | |
| parent | bcdb6022b3a300abf59cb5d0106c158940f5120e (diff) | |
eval-config: Support passing in `pkgs`
This is useful for flake users as they will usually already have an
instantiated Nixpkgs e.g.
let
pkgs = import nixpkgs {
config.allowUnfree = true;
overlays = [ ... ];
}
in darwin.lib.darwinSystem {
inherit pkgs;
}
This change makes `nix-darwin` match the behaviour of NixOS and
`home-manager`.
Diffstat (limited to 'eval-config.nix')
| -rw-r--r-- | eval-config.nix | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/eval-config.nix b/eval-config.nix index 719d764..af7849f 100644 --- a/eval-config.nix +++ b/eval-config.nix @@ -1,6 +1,7 @@ { lib }: { system ? builtins.currentSystem or "x86_64-darwin" +, pkgs ? null , modules , inputs , baseModules ? import ./modules/module-list.nix @@ -21,7 +22,15 @@ let pkgsModule = { config, inputs, ... }: { _file = ./eval-config.nix; config = { - _module.args.pkgs = import inputs.nixpkgs config.nixpkgs; + assertions = [ { + # Ensure that nixpkgs.* options are not set when pkgs is set + assertion = pkgs == null || (config.nixpkgs.config == { } && config.nixpkgs.overlays == [ ]); + message = '' + `nixpkgs` options are disabled when `pkgs` is supplied through `darwinSystem`. + ''; + } ]; + + _module.args.pkgs = if pkgs != null then pkgs else import inputs.nixpkgs config.nixpkgs; # This permits the configuration to override the passed-in # system. @@ -35,7 +44,7 @@ let literalDocBook = super.literalDocBook or super.literalExample; }); - eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "system" ] // { + eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "pkgs" "system" ] // { modules = modules ++ [ argsModule pkgsModule ] ++ baseModules; specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs; }); |
