-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
201 lines (181 loc) · 6.53 KB
/
flake.nix
File metadata and controls
201 lines (181 loc) · 6.53 KB
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
{
description = "Aether - Private cloud infrastructure";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgsUnstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
quadlet-nix.url = "github:SEIAROTg/quadlet-nix";
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixpkgsUnstable, flake-utils, nixos-generators, disko, quadlet-nix, sops-nix }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
# Shared facts for all NixOS hosts (vm config, tf outputs, etc.)
facts = (import ./nix/lib/facts.nix { inherit pkgs; }).facts;
# Shared specialArgs for all NixOS configurations
sharedSpecialArgs = { inherit facts; };
# Overlay to fix opentelemetry-collector-contrib in >= 24.11
# See: https://github.com/NixOS/nixpkgs/issues/368321
otelFixOverlay = final: prev: {
opentelemetry-collector-contrib =
let
pkg = prev.opentelemetry-collector-contrib;
in
if final.lib.versionOlder pkg.version "0.112" || final.lib.versionAtLeast pkg.version "0.114"
then pkg
else
let
commit = "17ddfd8ca1090321149a6d857110fd8eee856569";
opentelemetry-collector-builder = final.callPackage
(final.fetchurl {
url = "https://github.com/NixOS/nixpkgs/raw/${commit}/pkgs/tools/misc/opentelemetry-collector/builder.nix";
hash = "sha256-A46CZH8wQLDix3nYTWPx8ZJJoKbu0Nu36eTW5361TvU=";
})
{ };
opentelemetry-collector-releases = final.callPackage
(final.fetchurl {
url = "https://github.com/NixOS/nixpkgs/raw/${commit}/pkgs/tools/misc/opentelemetry-collector/releases.nix";
hash = "sha256-JBWakNxHDPI3vSdhBoZ+WQn5adahV1iigOOTm0fjrkQ=";
})
{ inherit opentelemetry-collector-builder; };
in
opentelemetry-collector-releases.otelcol-contrib;
};
# SSH CA key module - reads from environment variable at build time
# Build with: SSH_CA_PUBKEY="ecdsa-sha2..." nix build .#vm-base-image --impure
sshCaModule = { lib, ... }: {
aether.base.sshCaPubKey = builtins.getEnv "SSH_CA_PUBKEY";
};
# System-agnostic outputs (NixOS configurations)
# Build with: SSH_CA_PUBKEY="$(ssh root@step-ca cat /etc/step-ca/certs/ssh_user_ca_key.pub)" nixos-rebuild ... --impure
nixosConfigurations = {
adguard = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = sharedSpecialArgs;
modules = [
{ nixpkgs.overlays = [ otelFixOverlay ]; }
./nix/hosts/oracle/adguard.nix
sshCaModule
];
};
ids-stack = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = sharedSpecialArgs;
modules = [
{ nixpkgs.overlays = [ otelFixOverlay ]; }
quadlet-nix.nixosModules.quadlet
./nix/hosts/oracle/ids-stack
sshCaModule
];
};
blockchain-stack = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = sharedSpecialArgs;
modules = [
{ nixpkgs.overlays = [ otelFixOverlay ]; }
quadlet-nix.nixosModules.quadlet
./nix/hosts/smith/blockchain-stack
sshCaModule
];
};
openclaw = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = sharedSpecialArgs;
modules = [
{ nixpkgs.overlays = [ otelFixOverlay ]; }
quadlet-nix.nixosModules.quadlet
./nix/hosts/trinity/openclaw
sshCaModule
];
};
};
in
# Per-system outputs (dev shells + packages)
flake-utils.lib.eachDefaultSystem (sys:
let
pkgs = nixpkgs.legacyPackages.${sys};
pkgsUnstable = nixpkgsUnstable.legacyPackages.${sys};
in
{
# Dev shell - replaces Docker toolbox
devShells.default = pkgs.mkShell {
name = "aether";
packages = with pkgs; [
# Infrastructure as Code
opentofu
ansible
python3Packages.ansible-pylibssh # For network_cli connections (VyOS)
# Secrets management
sops
age
# Cloud CLIs
pkgsUnstable.awscli2
rclone # S3 CLI for AWS + Ceph RGW (MIT license)
# Certificate management
step-cli
# Utilities
jq
yq-go
curl
unzip
openssh
git
# Code quality
pre-commit
gitleaks
# Task runner
go-task
# OpenBao CLI (Vault fork)
openbao
# Kubernetes / Talos
talosctl # Talos cluster management
kubectl # Kubernetes CLI
cilium-cli # Cilium CNI management
istioctl # Istio service mesh CLI
kubernetes-helm # Helm charts
# GitLab
glab # GitLab CLI
];
shellHook = ''
echo "🚀 Aether dev shell loaded"
echo ""
'';
};
}
) // {
inherit nixosConfigurations;
# Base images for VMs and LXCs
# Build with: SSH_CA_PUBKEY="$(ssh root@step-ca cat /etc/step-ca/certs/ssh_user_ca_key.pub)" nix build .#vm-base-image --impure
packages.${system} = {
# qcow2 image for Terraform + cloud-init workflow
vm-base-image = nixos-generators.nixosGenerate {
inherit system;
format = "qcow";
modules = [
./nix/images/vm-base.nix
sshCaModule
];
};
lxc-base-image = nixos-generators.nixosGenerate {
inherit system;
format = "proxmox-lxc";
modules = [
./nix/images/lxc-base.nix
sshCaModule
];
};
};
};
}