1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-31 04:04:45 +00:00

Add support for extraModules input

NixOS offers the possibility to pass a list of extraModules to
lib.nixosSystem which later get merged with the modules list and
baseModules.
This offers the possibility to read additional modules from environment
files or a custom module-list.nix.

NixOS implementation is
[here](8601973cec/nixos/lib/eval-config.nix (L33)).

Dor nix-darwin an implementation was started in #592.
I restarted the implementation and removed the usage of
`NIXOS_EXTRA_MODULE_PATH` env variable because NixOS deprecated this
one.
This commit is contained in:
oliverwiegers 2025-01-27 15:31:54 +01:00
parent 62ba0a2242
commit ecc211e9a1
No known key found for this signature in database
GPG key ID: AFF11CB49BACA5D6
2 changed files with 7 additions and 4 deletions

View file

@ -17,6 +17,7 @@ in
{ lib
, modules
, baseModules ? import ./modules/module-list.nix
, extraModules ? []
, specialArgs ? { }
, check ? true
, enableNixpkgsReleaseCheck ? true
@ -72,14 +73,14 @@ let
_file = ./eval-config.nix;
config = {
_module.args = {
inherit baseModules modules;
inherit baseModules extraModules modules;
};
};
};
eval = lib.evalModules (builtins.removeAttrs args [ "lib" "enableNixpkgsReleaseCheck" ] // {
eval = lib.evalModules (builtins.removeAttrs args [ "lib" "enableNixpkgsReleaseCheck" "extraModules" ] // {
class = "darwin";
modules = modules ++ [ argsModule ] ++ baseModules;
modules = baseModules ++ extraModules ++ modules ++ [ argsModule ];
specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs;
});
in

View file

@ -18,11 +18,13 @@
lib = {
evalConfig = import ./eval-config.nix;
darwinSystem = args@{ modules, ... }: self.lib.evalConfig (
darwinSystem = args@{ modules, extraModules ? [], ... }: self.lib.evalConfig (
{ inherit (nixpkgs) lib; }
// nixpkgs.lib.optionalAttrs (args ? pkgs) { inherit (args.pkgs) lib; }
// builtins.removeAttrs args [ "system" "pkgs" "inputs" ]
// {
inherit extraModules;
modules = modules
++ nixpkgs.lib.optional (args ? pkgs) ({ lib, ... }: {
_module.args.pkgs = lib.mkForce args.pkgs;