198: hosts/devosSystem: pass modules as attrset r=nrdxp a=Pacman99

This is a fairly simple change that only changes the lib api for devosSystem. But doesn't add any features by itself. Hosts now pass modules to devosSystem as an attrset. And devosSystem just grabs all modules in the set and passes it to nixosSystem. 

I plan to use this in #197 to selectively import modules. And I think it could help with nix-darwin - and other config systems - support, since not all profiles and modules are config system agnostic. This could be a workaround to add rudimentary support for other config systems by only importing the necessary modules.

Overall I think its a useful change and extends the abilities of `devosSystem`

Co-authored-by: Pacman99 <pachum99@gmail.com>
This commit is contained in:
bors[bot] 2021-03-18 03:36:12 +00:00 committed by GitHub
commit 1b4edf3333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 57 deletions

View file

@ -13,54 +13,46 @@ let
suites = import ../suites { inherit lib; };
modules =
let
core = ../profiles/core;
modOverrides = { config, overrideModulesPath, ... }:
let
overrides = import ../overrides;
inherit (overrides) modules disabledModules;
in
{
disabledModules = modules ++ disabledModules;
imports = map
(path: "${overrideModulesPath}/${path}")
modules;
};
global = {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
hardware.enableRedistributableFirmware = lib.mkDefault true;
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${home}"
];
nixpkgs = { inherit pkgs; };
nix.registry = {
devos.flake = self;
nixos.flake = nixos;
override.flake = override;
};
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
modules = {
core = ../profiles/core;
modOverrides = { config, overrideModulesPath, ... }:
let
overrides = import ../overrides;
inherit (overrides) modules disabledModules;
in
{
disabledModules = modules ++ disabledModules;
imports = map
(path: "${overrideModulesPath}/${path}")
modules;
};
# Everything in `./modules/list.nix`.
flakeModules =
builtins.attrValues self.nixosModules;
global = {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
in
flakeModules ++ [
core
global
modOverrides
] ++ extern.modules;
hardware.enableRedistributableFirmware = lib.mkDefault true;
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${home}"
];
nixpkgs = { inherit pkgs; };
nix.registry = {
devos.flake = self;
nixos.flake = nixos;
override.flake = override;
};
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
# Everything in `./modules/list.nix`.
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
};
specialArgs = extern.specialArgs // { inherit suites; };
@ -79,19 +71,16 @@ let
(removeAttrs hosts [ hostName ]);
};
};
lib = {
lib = { inherit specialArgs; };
lib.testModule = {
imports = builtins.attrValues modules;
};
};
in
dev.os.devosSystem {
inherit system specialArgs;
modules = modules ++ [
local
{
lib = { inherit specialArgs; };
lib.testModule = {
imports = modules;
};
}
];
modules = modules // { inherit local lib; };
};
hosts = dev.os.recImport

View file

@ -4,12 +4,13 @@
lib.nixosSystem (args // {
modules =
let
moduleList = builtins.attrValues modules;
modpath = "nixos/modules";
cd = "installer/cd-dvd/installation-cd-minimal-new-kernel.nix";
isoConfig = (lib.nixosSystem
(args // {
modules = modules ++ [
modules = moduleList ++ [
"${nixos}/${modpath}/${cd}"
({ config, ... }: {
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
@ -58,7 +59,7 @@ lib.nixosSystem (args // {
];
})).config;
in
modules ++ [{
moduleList ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
};