From e3e5b8ae5178d99c48279e7eac7d5f61f0342fe9 Mon Sep 17 00:00:00 2001 From: Daniel Naab Date: Fri, 4 Dec 2026 08:16:30 -0600 Subject: [PATCH] infra(deploy): fix nixos-changed alert, /etc/nixos drift, stale smoke check Main deploys were broken from May 7 to Dec 4 because the deploy.nix fix (4c91e36) was never applied, and nothing surfaced that: - deploy-main posted the nixos-changed notification with status "warning", which the notify service rejects (success|failure|info), so the alert was never delivered. Use "failure". - `cli nixos apply` rebuilds from the worktree but never updated /etc/nixos, which deploy-main diffs against, so the "manual apply required" message fired even after an apply. Sync /etc/nixos after a successful rebuild. - The smoke check expected /projects to redirect to sign-in, but /projects has been public since ef11e37. Check /new instead. Pot-Run: 7979 --- infrastructure/nixos/modules/deploy.nix | 2 +- scripts/smoke-check.ts | 4 ++-- src/entrypoints/cli/commands/nixos.ts | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/infrastructure/nixos/modules/deploy.nix b/infrastructure/nixos/modules/deploy.nix index 809ef3533..a21932672 100644 --- a/infrastructure/nixos/modules/deploy.nix +++ b/infrastructure/nixos/modules/deploy.nix @@ -25,7 +25,7 @@ let # Notify via the notification service ${pkgs.curl}/bin/curl -s -X POST http://localhost:9001/event \ -H "Content-Type: application/json" \ - -d "{\"type\":\"deploy.nixos-changed\",\"title\":\"NixOS config changed in $SHA\",\"status\":\"warning\",\"details\":\"Manual apply required: bun run cli nixos apply\"}" \ + -d "{\"type\":\"deploy.nixos-changed\",\"title\":\"NixOS config changed in $SHA\",\"status\":\"failure\",\"details\":\"Manual apply required: bun run cli nixos apply\"}" \ || true else echo "No NixOS config changes" diff --git a/scripts/smoke-check.ts b/scripts/smoke-check.ts index e22162320..42c8acd47 100644 --- a/scripts/smoke-check.ts +++ b/scripts/smoke-check.ts @@ -37,9 +37,9 @@ const checks: Check[] = [ }, }, { - name: 'Auth guard protects /projects', + name: 'Auth guard protects /new', async run() { - const res = await fetch(`${baseUrl}/projects`, { redirect: 'manual' }) + const res = await fetch(`${baseUrl}/new`, { redirect: 'manual' }) if (res.status !== 302) throw new Error(`Expected 302, got ${res.status}`) const location = res.headers.get('Location') ?? '' if (!location.includes('/auth/signin')) diff --git a/src/entrypoints/cli/commands/nixos.ts b/src/entrypoints/cli/commands/nixos.ts index eb905b577..a443e413a 100644 --- a/src/entrypoints/cli/commands/nixos.ts +++ b/src/entrypoints/cli/commands/nixos.ts @@ -151,6 +151,9 @@ export async function nixos(args: string[]): Promise { `git config --global --add safe.directory ${worktree} 2>/dev/null || true`, `cd ${worktree}`, `nixos-rebuild switch --flake ./infrastructure/nixos#${flakeTarget}`, + // Record the applied config in /etc/nixos: forms-lab-deploy-main + // diffs against it to decide whether a manual apply is pending. + `cp -rT ./infrastructure/nixos /etc/nixos`, ].join(' && '), )