-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
164 lines (140 loc) · 4.72 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
/**
* This `flake.nix` file provides a comprehensive NixOS deployment configuration managed via Colmena.
* It defines multiple host configurations and organizes inputs into categories such as Nixpkgs, Home Manager, Security, and more.
*
* **Usage:**
* - **Deploy Configurations:**
* Use `nixos-rebuild` or `colmena` commands to deploy or update host configurations.
* Example: `colmena deploy -f .#hostname`
*
* - **Manage Inputs:**
* Modify inputs within their respective categories for updates and maintenance.
*
* - **Handle Secrets:**
* Securely manage secrets via `nix-secrets`. Update the `vars.varsFile` as required.
*
* - **Extend Configurations:**
* Add new host configurations by updating `hostConfigs` and user definitions.
*/
{
description = "Full-deployment NixOS flake";
inputs = {
### Nixpkgs
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable-small";
### NixOS Hardware repo
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
### Home Manager repo
home-manager = {
url = "github:nix-community/home-manager/master"; # Unstable
inputs.nixpkgs.follows = "nixpkgs";
};
### Secure boot
lanzaboote = {
url = "github:nix-community/lanzaboote/v0.4.1";
inputs.nixpkgs.follows = "nixpkgs";
};
# Secrets
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-secrets = {
url = "git+ssh://[email protected]/telometto/nix-secrets.git";
flake = true;
};
### VPN confinement repo
vpn-confinement = { url = "github:Maroka-chan/VPN-Confinement"; };
### Virtualization
microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
### Security
crowdsec = {
url = "git+https://codeberg.org/kampka/nix-flake-crowdsec.git";
inputs.nixpkgs.follows = "nixpkgs";
};
### File systems
disko = {
url = "github:nix-community/disko/latest";
inputs.nixpkgs.follows = "nixpkgs";
};
### Pimping
base16 = { url = "github:SenchoPens/base16.nix"; };
tt-schemes = {
url = "github:tinted-theming/schemes";
flake = false;
};
### Desktop environments
hyprland = { url = "github:hyprwm/Hyprland"; };
### NixOps
colmena = { url = "github:zhaofengli/colmena"; inputs.nixpkgs.follows = "nixpkgs"; };
# Nixarr repo (test)
#nixarr.url = "github:rasmus-kirk/nixarr";
};
outputs = inputs@{ self, nixpkgs, ... }:
let
VARS = import inputs.nix-secrets.vars.varsFile;
hostUsers = {
snowfall = [ VARS.users.admin.user ];
blizzard = [ VARS.users.admin.user ];
avalanche = [ VARS.users.admin.user VARS.users.frankie.user VARS.users.luke.user ];
};
# Define a function to generate host configurations
mkConfig = host: nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
# Start Home Manager configuration
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
sharedModules = [
inputs.sops-nix.homeManagerModules.sops
inputs.hyprland.homeManagerModules.default
];
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "hm-backup";
extraSpecialArgs = { inherit inputs VARS; };
users = nixpkgs.lib.genAttrs hostUsers.${host} (user:
import ./hosts/${host}/home/users/${if user == VARS.users.admin.user then "admin" else "extra/${user}"}/home.nix
);
};
}
] ++ hostConfigs.${host};
specialArgs = { inherit inputs VARS; };
};
hostConfigs = {
snowfall = [ ./hosts/snowfall/configuration.nix ];
blizzard = [ ./hosts/blizzard/configuration.nix ];
avalanche = [ ./hosts/avalanche/configuration.nix ];
};
in
{
colmena = {
meta = {
# name = "homelab";
# description = "My colmena homelab";
nixpkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ ];
};
specialArgs = { inherit inputs VARS; };
};
snowfall = ./hosts/snowfall;
# blizzard = ./hosts/blizzard;
# avalanche = ./hosts/avalanche;
};
nixosConfigurations = {
snowfall = mkConfig "snowfall";
blizzard = mkConfig "blizzard";
avalanche = mkConfig "avalanche";
};
};
}