-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
196 lines (181 loc) · 6.14 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
{
description = "nix-servers";
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Lix
# lix = {
# url = "git+https://git.lix.systems/lix-project/lix?ref=refs/tags/2.90-beta.1";
# flake = false;
# };
lix-module = {
url = "git+https://git.lix.systems/lix-project/nixos-module";
inputs.nixpkgs.follows = "nixpkgs";
};
# Disko
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
# SOPS Nix
sops-nix.url = "github:Mic92/sops-nix";
# Flake-Utils
flake-utils.url = "github:numtide/flake-utils";
# Colmena
colmena.url = "github:zhaofengli/colmena/main";
colmena.inputs.nixpkgs.follows = "nixpkgs";
# Attic
attic.url = "github:zhaofengli/attic";
# Nix-Topology
nix-topology.url = "github:oddlama/nix-topology";
# NixOS-DNS
# peterablehmann/NixOS-DNS/tree/fix-cnames
nixos-dns.url = "github:Janik-Haag/NixOS-DNS";
nixos-dns.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{ self
, nixpkgs
, lix-module
, disko
, sops-nix
, flake-utils
, colmena
, attic
, nix-topology
, nixos-dns
, ...
} @ inputs:
let
inherit (self) outputs;
# let's filter the installer configuration since we don't want to deploy it with colmena
conf = builtins.removeAttrs self.nixosConfigurations [ "home-installer" ];
in
(flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
# pkgs is needed here because colmena would otherwise be in the scope two times
pkgs.colmena
sops
jq
octodns
octodns-providers.bind
octodns-providers.hetzner
];
};
})) //
{
colmena = {
# see for details:
# https://github.com/zhaofengli/colmena/issues/60#issuecomment-1510496861
meta = {
nixpkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
nodeSpecialArgs = builtins.mapAttrs (name: value: value._module.specialArgs) conf;
};
} // builtins.mapAttrs (name: value: { imports = value._module.args.modules; }) conf;
nixosConfigurations = {
home-installer = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./installers/home
];
};
erik = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
system = "x86_64-linux";
extraModules = [ inputs.colmena.nixosModules.deploymentOptions ];
modules = [
./nodes/erik
self.nixosModules.common
nix-topology.nixosModules.default
];
};
heptifili = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
system = "x86_64-linux";
extraModules = [ inputs.colmena.nixosModules.deploymentOptions ];
modules = [
./nodes/heptifili
self.nixosModules.common
nix-topology.nixosModules.default
];
};
mns = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
system = "x86_64-linux";
extraModules = [ inputs.colmena.nixosModules.deploymentOptions ];
modules = [
./nodes/mns
self.nixosModules.common
nix-topology.nixosModules.default
];
};
ymir = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
system = "x86_64-linux";
extraModules = [ inputs.colmena.nixosModules.deploymentOptions ];
modules = [
./nodes/ymir
self.nixosModules.common
nix-topology.nixosModules.default
];
};
};
nixosModules = {
common = ./modules/common;
monitoring = ./modules/monitoring;
netbox = ./modules/netbox.nix;
kanidm = ./modules/kanidm.nix;
keycloak = ./modules/keycloak.nix;
paperless = ./modules/paperless.nix;
pdns-recursor = ./modules/pdns-recursor.nix;
syncthing = ./modules/syncthing.nix;
uptime-kuma = ./modules/uptime-kuma.nix;
unbound = ./modules/unbound.nix;
restic-server = ./modules/restic-server;
nextcloud = ./modules/nextcloud.nix;
radicale = ./modules/radicale;
};
dns = (nixos-dns.utils.generate nixpkgs.legacyPackages.x86_64-linux).octodnsConfig {
dnsConfig = {
inherit (self) nixosConfigurations;
extraConfig = import ./dns.nix;
};
config = {
providers = {
hetzner = {
class = "octodns_hetzner.HetznerProvider";
token = "env/HETZNER_DNS_API";
};
};
};
zones = {
"bigdriver.net." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
"hainsacker.de." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
"lehmann.ing." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
"lehmann.zone." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
"uic-fahrzeugnummer.de." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
"xnee.de." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
"xnee.net." = nixos-dns.utils.octodns.generateZoneAttrs [ "hetzner" ];
};
};
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
} // flake-utils.lib.eachDefaultSystem (system: rec {
pkgs = import nixpkgs {
inherit system;
overlays = [ nix-topology.overlays.default ];
};
topology = import nix-topology {
inherit pkgs;
modules = [
# Your own file to define global topology. Works in principle like a nixos module but uses different options.
# ./topology.nix
# Inline module to inform topology of your existing NixOS hosts.
./topology.nix
{ inherit (self) nixosConfigurations; }
];
};
});
}