feat(nixos): add activation guard preventing example.test domain deployment
Core Architecture & Invariant CI / validate (pull_request) Successful in 1m16s
Core Architecture & Invariant CI / validate (push) Successful in 1m19s

- Add system.activationScripts.checkHomelabDomain that aborts activation
  if homelab.domain defaults to 'example.test'
- Prevents silent deployment with placeholder domains when --impure flag
  is omitted from nixos-rebuild
- Guard runs only during activation (not during nix eval), so workstation
  tests remain unaffected
This commit is contained in:
kiskaadee committed 2026-11-17 16:59:50 -05:00
1 parent a5826e0e74
commit 514409939d
1 file changed
+12
+12
View File
@@ -32,6 +32,18 @@
domainParts = lib.splitString "." config.homelab.domain; domainParts = lib.splitString "." config.homelab.domain;
ldapBaseDn = lib.concatStringsSep "," (map (part: "dc=${part}") domainParts); ldapBaseDn = lib.concatStringsSep "," (map (part: "dc=${part}") domainParts);
in { in {
# ── Host Activation Guard ────────────────────────────────────────────────────
# Prevents activating on a live host if homelab.domain defaulted to example.test (e.g. forgot --impure)
system.activationScripts.checkHomelabDomain = {
text = ''
if [ "${config.homelab.domain}" = "example.test" ]; then
echo "❌ [homelab] FATAL: homelab.domain is defaulting to 'example.test'!" >&2
echo "❌ [homelab] Did you run 'nixos-rebuild switch' without the '--impure' flag?" >&2
echo "❌ [homelab] To activate properly: sudo nixos-rebuild switch --flake path:/home/operator/Core#server --impure" >&2
exit 1
fi
'';
};
# Define the keys to decrypt from secrets.yaml # Define the keys to decrypt from secrets.yaml
sops.secrets = (lib.genAttrs [ sops.secrets = (lib.genAttrs [
"dynu/api_key" "dynu/api_key"