Skip to content

Commit 1b4edf3

Browse files
bors[bot]Pacman99
and
Pacman99
authored
Merge #198
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>
2 parents 8ee3342 + dd494fa commit 1b4edf3

File tree

2 files changed

+42
-52
lines changed

2 files changed

+42
-52
lines changed

hosts/default.nix

+39-50
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,46 @@ let
1313

1414
suites = import ../suites { inherit lib; };
1515

16-
modules =
17-
let
18-
core = ../profiles/core;
19-
modOverrides = { config, overrideModulesPath, ... }:
20-
let
21-
overrides = import ../overrides;
22-
inherit (overrides) modules disabledModules;
23-
in
24-
{
25-
disabledModules = modules ++ disabledModules;
26-
imports = map
27-
(path: "${overrideModulesPath}/${path}")
28-
modules;
29-
};
16+
modules = {
17+
core = ../profiles/core;
18+
modOverrides = { config, overrideModulesPath, ... }:
19+
let
20+
overrides = import ../overrides;
21+
inherit (overrides) modules disabledModules;
22+
in
23+
{
24+
disabledModules = modules ++ disabledModules;
25+
imports = map
26+
(path: "${overrideModulesPath}/${path}")
27+
modules;
28+
};
3029

31-
global = {
32-
home-manager.useGlobalPkgs = true;
33-
home-manager.useUserPackages = true;
30+
global = {
31+
home-manager.useGlobalPkgs = true;
32+
home-manager.useUserPackages = true;
3433

35-
hardware.enableRedistributableFirmware = lib.mkDefault true;
34+
hardware.enableRedistributableFirmware = lib.mkDefault true;
3635

37-
nix.nixPath = [
38-
"nixpkgs=${nixos}"
39-
"nixos-config=${self}/compat/nixos"
40-
"home-manager=${home}"
41-
];
42-
43-
nixpkgs = { inherit pkgs; };
36+
nix.nixPath = [
37+
"nixpkgs=${nixos}"
38+
"nixos-config=${self}/compat/nixos"
39+
"home-manager=${home}"
40+
];
4441

45-
nix.registry = {
46-
devos.flake = self;
47-
nixos.flake = nixos;
48-
override.flake = override;
49-
};
42+
nixpkgs = { inherit pkgs; };
5043

51-
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
44+
nix.registry = {
45+
devos.flake = self;
46+
nixos.flake = nixos;
47+
override.flake = override;
5248
};
5349

54-
# Everything in `./modules/list.nix`.
55-
flakeModules =
56-
builtins.attrValues self.nixosModules;
50+
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
51+
};
5752

58-
in
59-
flakeModules ++ [
60-
core
61-
global
62-
modOverrides
63-
] ++ extern.modules;
53+
# Everything in `./modules/list.nix`.
54+
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
55+
};
6456

6557
specialArgs = extern.specialArgs // { inherit suites; };
6658

@@ -79,19 +71,16 @@ let
7971
(removeAttrs hosts [ hostName ]);
8072
};
8173
};
74+
lib = {
75+
lib = { inherit specialArgs; };
76+
lib.testModule = {
77+
imports = builtins.attrValues modules;
78+
};
79+
};
8280
in
8381
dev.os.devosSystem {
8482
inherit system specialArgs;
85-
86-
modules = modules ++ [
87-
local
88-
{
89-
lib = { inherit specialArgs; };
90-
lib.testModule = {
91-
imports = modules;
92-
};
93-
}
94-
];
83+
modules = modules // { inherit local lib; };
9584
};
9685

9786
hosts = dev.os.recImport

lib/devos/devosSystem.nix

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
lib.nixosSystem (args // {
55
modules =
66
let
7+
moduleList = builtins.attrValues modules;
78
modpath = "nixos/modules";
89
cd = "installer/cd-dvd/installation-cd-minimal-new-kernel.nix";
910

1011
isoConfig = (lib.nixosSystem
1112
(args // {
12-
modules = modules ++ [
13+
modules = moduleList ++ [
1314
"${nixos}/${modpath}/${cd}"
1415
({ config, ... }: {
1516
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
@@ -58,7 +59,7 @@ lib.nixosSystem (args // {
5859
];
5960
})).config;
6061
in
61-
modules ++ [{
62+
moduleList ++ [{
6263
system.build = {
6364
iso = isoConfig.system.build.isoImage;
6465
};

0 commit comments

Comments
 (0)