-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
158 lines (158 loc) · 4.41 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
{
description = "a nix derivation collection by nickcao";
inputs = {
nixpkgs.url = "github:NickCao/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
impermanence.url = "github:nix-community/impermanence";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
dns = {
url = "github:NickCao/dns.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
ranet = {
url = "github:NickCao/ranet/wireguard";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
ranet-ipsec = {
url = "github:NickCao/ranet";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
colmena = {
url = "github:zhaofengli/colmena";
inputs.stable.follows = "nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
lanzaboote = {
url = "github:nix-community/lanzaboote";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
bouncer = {
url = "github:NickCao/bouncer";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
inputs@{
self,
nixpkgs,
flake-utils,
...
}:
let
data = builtins.fromJSON (builtins.readFile ./zones/data.json);
lib = inputs.nixpkgs.lib;
in
flake-utils.lib.eachSystem
[
"aarch64-linux"
"x86_64-linux"
]
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
inputs.colmena.overlay
];
};
in
{
formatter = pkgs.nixpkgs-fmt;
legacyPackages = pkgs;
devShells.default =
with pkgs;
mkShell {
nativeBuildInputs = [
colmena
mdbook
nvfetcher
(opentofu.withPlugins (
ps: with ps; [
vultr
sops
hydra
hcloud
]
))
];
};
}
)
// {
nixosModules = import ./modules;
overlays.default =
final: prev:
prev.lib.packagesFromDirectoryRecursive {
inherit (prev) callPackage;
directory = ./pkgs;
};
nixosConfigurations = {
mainframe = import ./nixos/mainframe {
system = "x86_64-linux";
inherit self nixpkgs inputs;
};
} // self.colmenaHive.nodes;
colmenaHive = inputs.colmena.lib.makeHive (
{
meta = {
specialArgs = {
inherit self inputs;
data.nodes = data.nodes.value;
data.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOLQwaWXeJipSuAB+lV202yJOtAgJSNzuldH7JAf2jji"
"[email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAICKH4SwgJUkebLaYlrPsNDtnTNtoGRi3Qp/L6POetgySAAAACnNzaDptYXN0ZXI="
];
};
nixpkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
};
hydra =
{ ... }:
{
deployment.targetHost = "hydra";
imports = [ ./nixos/hydra ];
};
}
// (lib.mapAttrs (
name: value:
{ ... }:
{
deployment = {
targetHost = "${name}.nichi.link";
tags = value.tags;
};
imports =
if (builtins.elem "vultr" value.tags) then
(
lib.optionals (builtins.pathExists ./nixos/vultr/${name}) [ ./nixos/vultr/${name} ]
++ [
./nixos/vultr/common.nix
{ networking.hostName = name; }
]
)
else if (builtins.elem "hetzner" value.tags) then
[ ./nixos/hcloud/${name} ]
else
[ ./nixos/${name} ];
}
) data.nodes.value)
);
};
}