forked from TheMaxMur/NixOS-Configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
95 lines (86 loc) · 2.42 KB
/
default.nix
File metadata and controls
95 lines (86 loc) · 2.42 KB
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
{ self
, inputs
, ...
}:
let
homeConfiguration = "${self}/home";
systemConfiguration = "${self}/system";
homeModules = "${homeConfiguration}/modules";
systemModules = "${systemConfiguration}/modules";
commonModules = "${self}/modules";
# Helper function for generating host configs
mkHost = machineDir:
{ username ? "user"
, stateVersion ? "24.05"
, platform ? "x86_64-linux"
, hostname ? machineDir
, isWorkstation ? false
, wm ? null
}:
let
machineConfigurationPath = "${self}/system/machine/${machineDir}";
machineConfigurationPathExist = builtins.pathExists machineConfigurationPath;
machineModulesPath = "${self}/system/machine/${machineDir}/modules";
machineModulesPathExist = builtins.pathExists machineModulesPath;
swayEnable = wm == "sway";
hyprlandEnable = wm == "hyprland";
wmEnable = hyprlandEnable || swayEnable;
in inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
self
hostname
username
stateVersion
platform
machineDir
isWorkstation
wm
homeModules
commonModules
systemModules
machineConfigurationPath
machineConfigurationPathExist
machineModulesPath
machineModulesPathExist
hyprlandEnable
swayEnable
wmEnable;
};
modules = [
"${systemConfiguration}"
"${homeConfiguration}"
];
};
# Helper function for generating darwin host configs
mkHostDarwin = hostname:
{ username ? "user"
, stateVersion ? 6
, platform ? "aarch64-darwin"
}:
inputs.darwin.lib.darwinSystem {
specialArgs = {
inherit
inputs
self
hostname
username
platform
stateVersion
systemModules
commonModules;
};
modules = [
"${systemConfiguration}"
"${homeConfiguration}"
];
};
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;
}