-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdefault.nix
134 lines (126 loc) · 3.09 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
self,
inputs,
...
}:
let
defaultStateVersion = "24.11";
constructors = [
"${self}/home"
"${self}/system"
];
allDirs =
dirName:
builtins.filter (
module: ((builtins.pathExists module) && ((builtins.readFileType module) == "directory"))
) (map (module: "${dirName}/${module}") (builtins.attrNames (builtins.readDir dirName)));
# Helper function for generating host configs
mkHost =
machineDir:
{
username ? "user",
stateVersion ? defaultStateVersion,
hmStateVersion ? stateVersion,
platform ? "x86_64-linux",
hostname ? machineDir,
isWorkstation ? false,
wm ? null,
hostType ? "nixos",
}:
let
swayEnable = wm == "sway";
hyprlandEnable = wm == "hyprland";
wmEnable = hyprlandEnable || swayEnable;
in
inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
self
allDirs
hostname
username
stateVersion
hmStateVersion
platform
machineDir
isWorkstation
wm
hyprlandEnable
swayEnable
wmEnable
hostType
;
};
modules =
with inputs;
[
home-manager.nixosModules.home-manager
stylix.nixosModules.stylix
impermanence.nixosModules.impermanence
disko.nixosModules.disko
lanzaboote.nixosModules.lanzaboote
chaotic.nixosModules.default
nix-topology.nixosModules.default
nur.modules.nixos.default
proxmox-nixos.nixosModules.proxmox-ve
sops-nix.nixosModules.sops
nur.modules.nixos.default
]
++ constructors;
};
# Helper function for generating darwin host configs
mkHostDarwin =
machineDir:
{
username ? "user",
stateVersion ? 6,
hmStateVersion ? defaultStateVersion,
hostname ? machineDir,
platform ? "aarch64-darwin",
isWorkstation ? false,
wm ? null,
hostType ? "darwin",
}:
let
swayEnable = wm == "sway";
hyprlandEnable = wm == "hyprland";
wmEnable = hyprlandEnable || swayEnable;
in
inputs.darwin.lib.darwinSystem {
specialArgs = {
inherit
inputs
self
allDirs
hostname
username
platform
isWorkstation
machineDir
stateVersion
hmStateVersion
wm
hyprlandEnable
swayEnable
wmEnable
hostType
;
};
modules =
with inputs;
[
home-manager.darwinModules.home-manager
stylix.darwinModules.stylix
]
++ constructors;
};
in
{
forAllSystems = inputs.nixpkgs.lib.systems.flakeExposed;
# This function just add mkHost or mkHostDarwin before hosts attrset
# ex: pcbox = { username = "test"; stateVersion = "24.11"; }; ->
# pcbox = mkHost { username = "test"; stateVersion = "24.11"; };
genNixos = builtins.mapAttrs mkHost;
genDarwin = builtins.mapAttrs mkHostDarwin;
}