|
1 | | -{ self |
2 | | -, inputs |
3 | | -, ... |
| 1 | +{ |
| 2 | + self, |
| 3 | + inputs, |
| 4 | + ... |
4 | 5 | }: |
5 | 6 |
|
6 | 7 | let |
7 | 8 | defaultStateVersion = "24.11"; |
8 | 9 |
|
| 10 | + constructors = [ |
| 11 | + "${self}/home" |
| 12 | + "${self}/system" |
| 13 | + ]; |
| 14 | + |
9 | 15 | allDirs = |
10 | 16 | dirName: |
11 | 17 | builtins.filter ( |
12 | 18 | module: ((builtins.pathExists module) && ((builtins.readFileType module) == "directory")) |
13 | 19 | ) (map (module: "${dirName}/${module}") (builtins.attrNames (builtins.readDir dirName))); |
14 | 20 |
|
15 | 21 | # 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", |
24 | 33 | }: |
25 | 34 | let |
26 | | - swayEnable = wm == "sway"; |
| 35 | + swayEnable = wm == "sway"; |
27 | 36 | hyprlandEnable = wm == "hyprland"; |
28 | | - wmEnable = hyprlandEnable || swayEnable; |
29 | | - in inputs.nixpkgs.lib.nixosSystem { |
| 37 | + wmEnable = hyprlandEnable || swayEnable; |
| 38 | + in |
| 39 | + inputs.nixpkgs.lib.nixosSystem { |
30 | 40 | specialArgs = { |
31 | | - inherit |
| 41 | + inherit |
32 | 42 | inputs |
33 | 43 | self |
34 | 44 | allDirs |
|
42 | 52 | wm |
43 | 53 | hyprlandEnable |
44 | 54 | swayEnable |
45 | | - wmEnable; |
| 55 | + wmEnable |
| 56 | + hostType |
| 57 | + ; |
46 | 58 | }; |
47 | 59 |
|
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; |
64 | 76 | }; |
65 | 77 |
|
66 | 78 | # 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", |
75 | 90 | }: |
76 | 91 | let |
77 | | - swayEnable = wm == "sway"; |
| 92 | + swayEnable = wm == "sway"; |
78 | 93 | hyprlandEnable = wm == "hyprland"; |
79 | | - wmEnable = hyprlandEnable || swayEnable; |
80 | | - in inputs.darwin.lib.darwinSystem { |
| 94 | + wmEnable = hyprlandEnable || swayEnable; |
| 95 | + in |
| 96 | + inputs.darwin.lib.darwinSystem { |
81 | 97 | specialArgs = { |
82 | | - inherit |
| 98 | + inherit |
83 | 99 | inputs |
84 | 100 | self |
85 | 101 | allDirs |
|
93 | 109 | wm |
94 | 110 | hyprlandEnable |
95 | 111 | swayEnable |
96 | | - wmEnable; |
| 112 | + wmEnable |
| 113 | + hostType |
| 114 | + ; |
97 | 115 | }; |
98 | 116 |
|
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; |
107 | 124 | }; |
108 | | -in { |
| 125 | +in |
| 126 | +{ |
109 | 127 | forAllSystems = inputs.nixpkgs.lib.systems.flakeExposed; |
110 | 128 |
|
111 | 129 | # This function just add mkHost or mkHostDarwin before hosts attrset |
112 | 130 | # ex: pcbox = { username = "test"; stateVersion = "24.11"; }; -> |
113 | 131 | # pcbox = mkHost { username = "test"; stateVersion = "24.11"; }; |
114 | | - genNixos = builtins.mapAttrs mkHost; |
| 132 | + genNixos = builtins.mapAttrs mkHost; |
115 | 133 | genDarwin = builtins.mapAttrs mkHostDarwin; |
116 | 134 | } |
117 | | - |
|
0 commit comments