-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
221 lines (193 loc) · 7.33 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
{
description = "TK's Nix Configs";
inputs = {
# Nixpkgs Stable - https://github.com/NixOS/nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
# Nixpkgs Version 2311 - https://github.com/NixOS/nixpkgs
nixpkgs-v2311.url = "github:nixos/nixpkgs/nixos-23.11";
# Nixpkgs Unstable
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
# Disko (Disk Config)
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
# Home Manager - https://github.com/nix-community/home-manager
home-manager.url = "github:nix-community/home-manager/release-24.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Atomic, declarative, and reproducible secret provisioning for NixOS based on sops.
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
# For VS Code Remote to work on NixOS
vscode-server.url = "github:nix-community/nixos-vscode-server";
# Community VS Code Extensions
nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
# For managing KDE Plasma 5
plasma-manager5.url = "github:pjones/plasma-manager/plasma-5";
plasma-manager5.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager5.inputs.home-manager.follows = "home-manager";
# For manaing KDE Plasma 6
plasma-manager6.url = "github:nix-community/plasma-manager";
plasma-manager6.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager6.inputs.home-manager.follows = "home-manager";
# Deploy-rs
deploy-rs.url = "github:serokell/deploy-rs";
# NixOS Hardware
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
};
outputs = { self, nixpkgs, home-manager, ... } @ inputs:
let
inherit (self) outputs;
lib = nixpkgs.lib // home-manager.lib;
# Supported systems for your flake packages, shell, etc.
systems = [
"aarch64-linux"
"i686-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
forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system});
pkgsFor = lib.genAttrs systems (system: import nixpkgs {
inherit system;
config.allowUnfree = true;
# Temporary
config.permittedInsecurePackages = [
"electron-27.3.11"
];
});
in
{
inherit lib;
# Reusable nixos modules you might want to export (shareable)
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit inputs;};
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; });
# Formatter for your nix files, available through 'nix fmt'
formatter = forEachSystem (pkgs: pkgs.alejandra);
# DevShells for each system
devShells = forEachSystem (pkgs: import ./shell.nix { inherit pkgs; });
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
router = lib.nixosSystem {
modules = [ ./hosts/router ];
specialArgs = {inherit inputs outputs;};
};
dockerhost = lib.nixosSystem {
modules = [ ./hosts/dockerhost ];
specialArgs = {inherit inputs outputs;};
};
beltanimal = lib.nixosSystem {
modules = [ ./hosts/beltanimal ];
specialArgs = {inherit inputs outputs;};
};
anya = lib.nixosSystem {
modules = [ ./hosts/anya ];
specialArgs = {inherit inputs outputs;};
};
hummingbird = lib.nixosSystem {
modules = [ ./hosts/hummingbird ];
specialArgs = {inherit inputs outputs;};
};
tailscale = lib.nixosSystem {
modules = [ ./hosts/tailscale ];
specialArgs = {inherit inputs outputs;};
};
ca = lib.nixosSystem {
modules = [ ./hosts/ca ];
specialArgs = {inherit inputs outputs;};
};
nextcloud = lib.nixosSystem {
modules = [ ./hosts/nextcloud ];
specialArgs = {inherit inputs outputs;};
};
};
# Available through 'home-manager --flake .#your-username@your-hostname'
# NOTE: Home-manager requires a 'pkgs' instance
homeConfigurations = {
# For Testing
"tk@nix-test" = lib.homeManagerConfiguration {
modules = [ ./home/tk/nix-test.nix ];
pkgs = pkgsFor.x86_64-linux;
extraSpecialArgs = let username = "tk"; in {inherit inputs outputs username;};
};
# Laptop
"tk@beltanimal" = lib.homeManagerConfiguration {
modules = [ ./home/tk/beltanimal.nix ];
pkgs = pkgsFor.x86_64-linux;
extraSpecialArgs = let username = "tk"; in {inherit inputs outputs username;};
};
"astra@beltanimal" = lib.homeManagerConfiguration {
modules = [ ./home/astra/beltanimal.nix ];
pkgs = pkgsFor.x86_64-linux;
extraSpecialArgs = let username = "astra"; in {inherit inputs outputs username;};
};
# Desktop 1
"tk@anya" = lib.homeManagerConfiguration {
modules = [ ./home/tk/anya.nix ];
pkgs = pkgsFor.x86_64-linux;
extraSpecialArgs = let username = "tk"; in {inherit inputs outputs username;};
};
# Desktop 2
"astra@hummingbird" = lib.homeManagerConfiguration {
modules = [ ./home/astra/hummingbird.nix ];
pkgs = pkgsFor.x86_64-linux;
extraSpecialArgs = let username = "astra"; in {inherit inputs outputs username;};
};
};
deploy.nodes = {
# Desktop
anya = {
hostname = "anya.cyn.internal";
profiles.system = {
sshUser = "tk";
user = "root";
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.anya;
};
profiles.tk = {
sshUser = "tk";
user = "tk";
path = inputs.deploy-rs.lib.x86_64-linux.activate.custom self.homeConfigurations."tk@anya".activationPackage "$PROFILE/activate";
};
};
# Laptop
beltanimal = {
hostname = "beltanimal.cyn.internal";
profiles.system = {
sshUser = "tk";
user = "root";
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.beltanimal;
};
profiles.tk = {
sshUser = "tk";
user = "tk";
path = inputs.deploy-rs.lib.x86_64-linux.activate.custom self.homeConfigurations."tk@beltanimal".activationPackage "$PROFILE/activate";
};
};
# Router
router = {
hostname = "router.cyn.internal";
profiles.system = {
sshUser = "tk";
user = "root";
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.router;
};
};
# Dockerhost
dockerhost = {
hostname = "dockerhost.cyn.internal";
profiles.system = {
sshUser = "tk";
user = "root";
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.dockerhost;
};
};
};
# (deploy-rs) This is highly advised, and will prevent many possible mistakes
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
};
}