-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
303 lines (275 loc) · 9.39 KB
/
flake.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
{
description = "NixOS configuration, Yay!";
inputs = {
# Nixpkgs
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
# You can access packages and modules from different nixpkgs revs
# at the same time. Here's an working example:
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# Also see the 'unstable-packages' overlay at 'overlays/default.nix'.
# Darwin
nixpkgs-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
homebrew-bundle = {
url = "github:homebrew/homebrew-bundle";
flake = false;
};
homebrew-core = {
url = "github:homebrew/homebrew-core";
flake = false;
};
homebrew-cask = {
url = "github:homebrew/homebrew-cask";
flake = false;
};
# Home manager
home-manager.url = "github:nix-community/home-manager/release-24.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs-stable";
# Any other flake needed
hardware.url = "github:nixos/nixos-hardware";
# AGS
ags = {
url = "github:Aylur/ags";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
# Dev
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
# Sops
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
# Agenix
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
# Nix Colors
nix-colors.url = "github:misterio77/nix-colors";
compose2nix = {
url = "github:aksiksi/compose2nix";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# Secrets
nix-secrets = {
url = "git+ssh://git@github.com/abayomi185/nix-secrets.git?ref=main&shallow=1";
flake = false;
};
# Brew Nix
brew-api = {
url = "github:BatteredBunny/brew-api";
flake = false;
};
brew-nix = {
url = "github:BatteredBunny/brew-nix";
inputs.brew-api.follows = "brew-api";
};
};
outputs = {
self,
agenix,
home-manager,
nix-colors,
nix-homebrew,
rust-overlay,
sops-nix,
...
} @ inputs: let
inherit (self) outputs;
# Supported systems for your flake packages, shell, etc.
systems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = inputs.nixpkgs-stable.lib.genAttrs systems;
in {
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
packages = forAllSystems (
system: let
pkgs = import inputs.nixpkgs-stable {
inherit system;
overlays = [(import rust-overlay)];
};
in
import ./pkgs {inherit pkgs;}
);
# Formatter for your nix files, available through 'nix fmt'
# Other options beside 'alejandra' include 'nixpkgs-fmt'
formatter = forAllSystems (system: inputs.nixpkgs-stable.legacyPackages.${system}.alejandra);
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit inputs;};
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = import ./modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
homeManagerModules = import ./modules/home-manager;
# For darwin-specific modules
darwinModules = import ./modules/darwin;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
# x1c6 = inputs.nixpkgs-stable.lib.nixosSystem {
# specialArgs = {inherit inputs outputs;};
# modules = [
# # > Our main nixos configuration file <
# ./hosts/x1c6/configuration.nix
# home-manager.nixosModules.home-manager
# {
# # home-manager.useGlobalPkgs = true;
# home-manager.useUserPackages = true;
# home-manager.extraSpecialArgs = {inherit inputs outputs nix-colors;};
# home-manager.users.yomi = import ./hosts/x1c6/home.nix;
# home-manager.sharedModules = [
# inputs.sops-nix.homeManagerModules.sops
# ];
# }
# ];
# };
vps-arm64 = inputs.nixpkgs-stable.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
# > Our main nixos configuration file <
./hosts/vps/configuration.nix
sops-nix.nixosModules.sops
agenix.nixosModules.default
home-manager.nixosModules.home-manager
{
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {inherit inputs outputs;};
home-manager.users.cloud = import ./hosts/vps/home.nix;
home-manager.sharedModules = [
inputs.sops-nix.homeManagerModules.sops
];
}
];
};
vm-game = inputs.nixpkgs-stable.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
# > Our main nixos configuration file <
./hosts/game/configuration.nix
sops-nix.nixosModules.sops
agenix.nixosModules.default
home-manager.nixosModules.home-manager
{
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {inherit inputs outputs;};
home-manager.users.cloud = import ./hosts/game/home.nix;
home-manager.sharedModules = [
inputs.sops-nix.homeManagerModules.sops
];
}
];
};
};
# Kubernetes cluster definition
nixosConfigurations = {
knode1 = import ./hosts/knode/default.nix {
inherit inputs outputs;
pNodeId = "1";
pK3sRole = "server";
pK3sClusterInit = true;
pK3sServerId = "";
};
knode2 = import ./hosts/knode/default.nix {
inherit inputs outputs;
pNodeId = "2";
pK3sRole = "server";
};
knode3 = import ./hosts/knode/default.nix {
inherit inputs outputs;
pNodeId = "3";
pK3sRole = "server";
};
};
darwinConfigurations = {
# MacBook Pro 18,2
MacBook-Pro = inputs.nixpkgs-darwin.lib.darwinSystem {
specialArgs = {
inherit inputs outputs;
};
modules = [
# > Our main nixos configuration file <
./hosts/mbp16/configuration.nix
agenix.darwinModules.default
home-manager.darwinModules.home-manager
nix-homebrew.darwinModules.nix-homebrew
{
nixpkgs.hostPlatform = "aarch64-darwin";
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {inherit inputs outputs nix-colors;};
home-manager.users.yomi = import ./hosts/mbp16/home.nix;
home-manager.sharedModules = [
inputs.sops-nix.homeManagerModules.sops
];
nix-homebrew.enable = true;
nix-homebrew.enableRosetta = true;
nix-homebrew.user = "yomi";
nix-homebrew.autoMigrate = true;
}
];
};
# MacBook Pro 18,3
MacBook-Pro-14 = inputs.nixpkgs-darwin.lib.darwinSystem {
specialArgs = {
inherit inputs outputs;
};
modules = [
# > Our main nixos configuration file <
./hosts/mbp14/configuration.nix
agenix.darwinModules.default
home-manager.darwinModules.home-manager
nix-homebrew.darwinModules.nix-homebrew
{
nixpkgs.hostPlatform = "aarch64-darwin";
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {inherit inputs outputs nix-colors;};
home-manager.users.yomi = import ./hosts/mbp14/home.nix;
home-manager.sharedModules = [
inputs.sops-nix.homeManagerModules.sops
];
nix-homebrew.enable = true;
nix-homebrew.enableRosetta = true;
nix-homebrew.user = "yomi";
nix-homebrew.autoMigrate = true;
}
];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
"yomi@A-MacBook-Pro-eth.lan" = home-manager.lib.homeManagerConfiguration {
pkgs = inputs.nixpkgs-stable.legacyPackages.aarch64-darwin; # Home-manager requires 'pkgs' instance
extraSpecialArgs = {inherit inputs outputs nix-colors;};
modules = [
./hosts/mbp16/home.nix
];
};
"yomi@MacBook-Pro-14.lan" = home-manager.lib.homeManagerConfiguration {
pkgs = inputs.nixpkgs-stable.legacyPackages.aarch64-darwin; # Home-manager requires 'pkgs' instance
extraSpecialArgs = {inherit inputs outputs nix-colors;};
modules = [
./hosts/mbp14/home.nix
];
};
};
};
}