Skip to content

Commit 1e3b0bb

Browse files
committed
lib: Fmt
1 parent a239a6e commit 1e3b0bb

File tree

1 file changed

+73
-56
lines changed

1 file changed

+73
-56
lines changed

lib/default.nix

Lines changed: 73 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
1-
{ self
2-
, inputs
3-
, ...
1+
{
2+
self,
3+
inputs,
4+
...
45
}:
56

67
let
78
defaultStateVersion = "24.11";
89

10+
constructors = [
11+
"${self}/home"
12+
"${self}/system"
13+
];
14+
915
allDirs =
1016
dirName:
1117
builtins.filter (
1218
module: ((builtins.pathExists module) && ((builtins.readFileType module) == "directory"))
1319
) (map (module: "${dirName}/${module}") (builtins.attrNames (builtins.readDir dirName)));
1420

1521
# Helper function for generating host configs
16-
mkHost = machineDir:
17-
{ username ? "user"
18-
, stateVersion ? defaultStateVersion
19-
, hmStateVersion ? stateVersion
20-
, platform ? "x86_64-linux"
21-
, hostname ? machineDir
22-
, isWorkstation ? false
23-
, wm ? null
22+
mkHost =
23+
machineDir:
24+
{
25+
username ? "user",
26+
stateVersion ? defaultStateVersion,
27+
hmStateVersion ? stateVersion,
28+
platform ? "x86_64-linux",
29+
hostname ? machineDir,
30+
isWorkstation ? false,
31+
wm ? null,
32+
hostType ? "nixos",
2433
}:
2534
let
26-
swayEnable = wm == "sway";
35+
swayEnable = wm == "sway";
2736
hyprlandEnable = wm == "hyprland";
28-
wmEnable = hyprlandEnable || swayEnable;
29-
in inputs.nixpkgs.lib.nixosSystem {
37+
wmEnable = hyprlandEnable || swayEnable;
38+
in
39+
inputs.nixpkgs.lib.nixosSystem {
3040
specialArgs = {
31-
inherit
41+
inherit
3242
inputs
3343
self
3444
allDirs
@@ -42,44 +52,50 @@ let
4252
wm
4353
hyprlandEnable
4454
swayEnable
45-
wmEnable;
55+
wmEnable
56+
hostType
57+
;
4658
};
4759

48-
modules = [
49-
inputs.home-manager.nixosModules.home-manager
50-
inputs.stylix.nixosModules.stylix
51-
inputs.impermanence.nixosModules.impermanence
52-
inputs.disko.nixosModules.disko
53-
inputs.lanzaboote.nixosModules.lanzaboote
54-
inputs.chaotic.nixosModules.default
55-
inputs.nix-topology.nixosModules.default
56-
inputs.nur.modules.nixos.default
57-
inputs.proxmox-nixos.nixosModules.proxmox-ve
58-
inputs.sops-nix.nixosModules.sops
59-
60-
"${self}/system/nixos/modules"
61-
"${self}/system"
62-
"${self}/home"
63-
];
60+
modules =
61+
with inputs;
62+
[
63+
home-manager.nixosModules.home-manager
64+
stylix.nixosModules.stylix
65+
impermanence.nixosModules.impermanence
66+
disko.nixosModules.disko
67+
lanzaboote.nixosModules.lanzaboote
68+
chaotic.nixosModules.default
69+
nix-topology.nixosModules.default
70+
nur.modules.nixos.default
71+
proxmox-nixos.nixosModules.proxmox-ve
72+
sops-nix.nixosModules.sops
73+
nur.modules.nixos.default
74+
]
75+
++ constructors;
6476
};
6577

6678
# Helper function for generating darwin host configs
67-
mkHostDarwin = machineDir:
68-
{ username ? "user"
69-
, stateVersion ? 6
70-
, hmStateVersion ? defaultStateVersion
71-
, hostname ? machineDir
72-
, platform ? "aarch64-darwin"
73-
, isWorkstation ? false
74-
, wm ? null
79+
mkHostDarwin =
80+
machineDir:
81+
{
82+
username ? "user",
83+
stateVersion ? 6,
84+
hmStateVersion ? defaultStateVersion,
85+
hostname ? machineDir,
86+
platform ? "aarch64-darwin",
87+
isWorkstation ? false,
88+
wm ? null,
89+
hostType ? "darwin",
7590
}:
7691
let
77-
swayEnable = wm == "sway";
92+
swayEnable = wm == "sway";
7893
hyprlandEnable = wm == "hyprland";
79-
wmEnable = hyprlandEnable || swayEnable;
80-
in inputs.darwin.lib.darwinSystem {
94+
wmEnable = hyprlandEnable || swayEnable;
95+
in
96+
inputs.darwin.lib.darwinSystem {
8197
specialArgs = {
82-
inherit
98+
inherit
8399
inputs
84100
self
85101
allDirs
@@ -93,25 +109,26 @@ let
93109
wm
94110
hyprlandEnable
95111
swayEnable
96-
wmEnable;
112+
wmEnable
113+
hostType
114+
;
97115
};
98116

99-
modules = [
100-
inputs.home-manager.darwinModules.home-manager
101-
inputs.stylix.darwinModules.stylix
102-
103-
"${self}/system/darwin/modules"
104-
"${self}/system"
105-
"${self}/home"
106-
];
117+
modules =
118+
with inputs;
119+
[
120+
home-manager.darwinModules.home-manager
121+
stylix.darwinModules.stylix
122+
]
123+
++ constructors;
107124
};
108-
in {
125+
in
126+
{
109127
forAllSystems = inputs.nixpkgs.lib.systems.flakeExposed;
110128

111129
# This function just add mkHost or mkHostDarwin before hosts attrset
112130
# ex: pcbox = { username = "test"; stateVersion = "24.11"; }; ->
113131
# pcbox = mkHost { username = "test"; stateVersion = "24.11"; };
114-
genNixos = builtins.mapAttrs mkHost;
132+
genNixos = builtins.mapAttrs mkHost;
115133
genDarwin = builtins.mapAttrs mkHostDarwin;
116134
}
117-

0 commit comments

Comments
 (0)