split _module.args and specialArgs

specialArgs are evaluated earlier and can therefore used in imports in
the module system. This is the difference in comparison to _module.args.
This commit is contained in:
Tobias Happ 2022-11-05 20:48:02 +01:00
parent 587825a1e4
commit d68467d679
3 changed files with 18 additions and 16 deletions

View file

@ -1,4 +1,4 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config ? null
, extraModules ? [ ]
@ -18,20 +18,11 @@ let
else if builtins.pathExists defaultConfigFile then defaultConfigFile
else pkgs.config.nix-on-droid or (throw "No config file found! Create one in ~/.config/nixpkgs/nix-on-droid.nix");
nodModules = import ./module-list.nix { inherit pkgs home-manager-path isFlake; };
rawModule = evalModules {
modules = [
{
_module.args =
{
inherit home-manager-path isFlake;
pkgs = mkDefault pkgs;
}
// extraSpecialArgs;
}
configModule
]
++ extraModules
++ import ./module-list.nix { inherit pkgs isFlake; };
modules = [ configModule ] ++ extraModules ++ nodModules;
specialArgs = extraSpecialArgs;
};
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions);

View file

@ -1,6 +1,6 @@
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE.
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ pkgs, isFlake }:
{ pkgs, home-manager-path, isFlake }:
[
./build/activation.nix
@ -22,4 +22,12 @@
./user.nix
./version.nix
(pkgs.path + "/nixos/modules/misc/assertions.nix")
{
_file = ./module-list.nix;
_module.args = {
inherit home-manager-path isFlake;
pkgs = pkgs.lib.mkDefault pkgs;
};
}
] ++ pkgs.lib.optionals (!isFlake) [ ./nixpkgs/config.nix ]