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

@ -13,6 +13,9 @@
* Add support for `nix profile` managed profiles * Add support for `nix profile` managed profiles
* Add possibilty to bootstrap Nix-on-Droid with flakes via prompt on initial * Add possibilty to bootstrap Nix-on-Droid with flakes via prompt on initial
boot boot
* Fix usage of `extraSpecialArgs`: All values were previously set in
`_module.args` instead of passing them as `specialArgs` into `evalModules`.
This enables usage of `specialArgs` to use in `imports` in module defintions.
## Release 22.05 ## Release 22.05

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 { config ? null
, extraModules ? [ ] , extraModules ? [ ]
@ -18,20 +18,11 @@ let
else if builtins.pathExists defaultConfigFile then defaultConfigFile 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"); 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 { rawModule = evalModules {
modules = [ modules = [ configModule ] ++ extraModules ++ nodModules;
{ specialArgs = extraSpecialArgs;
_module.args =
{
inherit home-manager-path isFlake;
pkgs = mkDefault pkgs;
}
// extraSpecialArgs;
}
configModule
]
++ extraModules
++ import ./module-list.nix { inherit pkgs isFlake; };
}; };
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions); 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 ./build/activation.nix
@ -22,4 +22,12 @@
./user.nix ./user.nix
./version.nix ./version.nix
(pkgs.path + "/nixos/modules/misc/assertions.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 ] ] ++ pkgs.lib.optionals (!isFlake) [ ./nixpkgs/config.nix ]