mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
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`.
This commit is contained in:
parent
bcdb6022b3
commit
5528b36698
3 changed files with 12 additions and 4 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -29,6 +29,5 @@
|
|||
system = "x86_64-darwin";
|
||||
modules = [ self.darwinModules.simple ];
|
||||
}).system;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
# _module.args.pkgs is defined in ../../default.nix
|
||||
# _module.args.pkgs is defined in ../../eval-config.nix
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue