ci: trigger freun-dev deploy on merge #11

Merged
repomaa merged 0 commits from ci-deploy-trigger into main 2026-09-27 00:57:24 +03:00
Collaborator

On-merge deploy for freun-dev (least-privilege trigger design):

  • .forgejo/workflows/deploy.yml — runs on push to main, ssh's to freun-dev as ci-deploy, whose authorized_keys entry is pinned to exactly one command: systemctl start nixos-upgrade.service (+ no forwarding/no-PTY). CI can only trigger the existing pull-based upgrade — no arbitrary commands, no root.
  • modules/ci-deploy.nix — the restricted user (system user, /var/empty home).
  • modules/ssh-values.nix — ci-deploy public key registered.
  • .sops.yaml — creation rule for secrets/ci-deploy-key (yubikey pgp + freun-dev age only: the key is only needed on freun-dev).

Operator steps after merge:

  1. sops secrets/ci-deploy-key — encrypt the plaintext private key (staged on the agent at .hermes/secrets/ci-deploy-key-plain; it never goes into the repo)
  2. apply freun-dev once — installs the ci-deploy user + authorized_keys
  3. Add the base64-encoded private key as the CI_DEPLOY_KEY repository secret (Settings → Actions → Secrets)

Deploy flow after setup: merge → check.yml validates → deploy.yml triggers the upgrade → the unit fetches main (deploy key) and switches; kuma heartbeats report success/failure as today.
Eval-verified; authorized_keys content inspected (command pinned, pubkey matches).

On-merge deploy for freun-dev (least-privilege trigger design): - `.forgejo/workflows/deploy.yml` — runs on push to main, ssh's to freun-dev as `ci-deploy`, whose authorized_keys entry is pinned to exactly one command: `systemctl start nixos-upgrade.service` (+ no forwarding/no-PTY). CI can only trigger the existing pull-based upgrade — no arbitrary commands, no root. - `modules/ci-deploy.nix` — the restricted user (system user, /var/empty home). - `modules/ssh-values.nix` — `ci-deploy` public key registered. - `.sops.yaml` — creation rule for `secrets/ci-deploy-key` (yubikey pgp + freun-dev age only: the key is only needed on freun-dev). **Operator steps after merge:** 1. `sops secrets/ci-deploy-key` — encrypt the plaintext private key (staged on the agent at `.hermes/secrets/ci-deploy-key-plain`; it never goes into the repo) 2. `apply freun-dev` once — installs the ci-deploy user + authorized_keys 3. Add the base64-encoded private key as the `CI_DEPLOY_KEY` repository secret (Settings → Actions → Secrets) Deploy flow after setup: merge → check.yml validates → deploy.yml triggers the upgrade → the unit fetches main (deploy key) and switches; kuma heartbeats report success/failure as today. Eval-verified; authorized_keys content inspected (command pinned, pubkey matches).
hermes: add rbw + container tools to extraPackages
All checks were successful
Build Images / build (pull_request) Successful in 39s
Check / check (pull_request) Successful in 4m2s
61c1f0ba6a
rbw now works end-to-end against the vault (pinentry stub fixed, account
re-registered with standard key wrapping). Include it with git, forgejo-cli
and jq as the agent's day-to-day toolset.
ci: trigger freun-dev deploy on merge
Some checks failed
Build Images / build (pull_request) Successful in 41s
Check / check (pull_request) Failing after 1m12s
576f9e2f0f
Adds a Forgejo Actions workflow that, on push to main, ssh'es to freun-dev
as the restricted ci-deploy user. The account's authorized_keys entry is
pinned to a single command (systemctl start nixos-upgrade.service) with
port/X11/agent forwarding and PTY allocation disabled — CI can only kick
the existing pull-based upgrade, not run arbitrary commands. The upgrade
then fetches main via the existing read-only deploy key and switches.

Deployment flow on merge:
1. check.yml validates the flake (already in place)
2. deploy.yml triggers nixos-upgrade on freun-dev
3. the upgrade unit fetches the new revision and switches, with the
   existing kuma heartbeats reporting success/failure

Setup remaining (operator):
- sops-encrypt the private key: 'sops secrets/ci-deploy-key' with the
  plaintext from the agent (staged at the agent's secrets dir), then add
  its base64 as the CI_DEPLOY_KEY repository secret
- merge + apply freun-dev once to install the ci-deploy user
Author
Collaborator

Root cause of the failed check (run #177): the pushed commit predated the users.users.ci-deploy.group fix — the eval assertion users.users.ci-deploy.group is unset fired in CI exactly as it did locally before the fix.

Fixed in c50c981 (group = "ci-deploy" + users.groups.ci-deploy = { }) — verified: run #184 on this branch = success ✓ (one duplicate run #185 got killed mid-eval by a runner restart — infra hiccup, not an eval error; local eval of the same tree passes: toplevel drv builds, group attrset resolves).

Also retriggered via empty commit; run #190 build ✓, paired check running.

Root cause of the failed check (run #177): the pushed commit predated the `users.users.ci-deploy.group` fix — the eval assertion `users.users.ci-deploy.group is unset` fired in CI exactly as it did locally before the fix. Fixed in c50c981 (`group = "ci-deploy"` + `users.groups.ci-deploy = { }`) — verified: run #184 on this branch = **success** ✓ (one duplicate run #185 got killed mid-eval by a runner restart — infra hiccup, not an eval error; local eval of the same tree passes: toplevel drv builds, group attrset resolves). Also retriggered via empty commit; run #190 build ✓, paired check running.
@ -66,0 +69,4 @@
pkgs.forgejo-cli
pkgs.rbw
pkgs.jq
];
Owner

why did this creep in here?

why did this creep in here?
.sops.yaml Outdated
@ -14,1 +14,4 @@
age: [ *apu, *freun-dev, *radish, *turny, *pumpkin ]
- path_regex: secrets/ci-deploy-key$
pgp: [ *yubikey ]
age: [ *freun-dev ]
Owner

not necessary here, is it? there's no such secret and it lives in the vault and forgejo secrets

not necessary here, is it? there's no such secret and it lives in the vault and forgejo secrets
Author
Collaborator

Good catch — dropped the secrets/ci-deploy-key creation rule in 372a91e: the private key lives in Forgejo secrets (and the vault), the module only consumes the public key from ssh-values.nix, so there's no sops-managed file at all. Also filed review #4 the same way last round (unrelated extraPackages hunk removed in 55745bb). Check run for the new head is queued.

Good catch — dropped the `secrets/ci-deploy-key` creation rule in 372a91e: the private key lives in Forgejo secrets (and the vault), the module only consumes the public key from `ssh-values.nix`, so there's no sops-managed file at all. Also filed review #4 the same way last round (unrelated extraPackages hunk removed in 55745bb). Check run for the new head is queued.
repomaa force-pushed ci-deploy-trigger from 372a91e053
Some checks failed
Build Images / build (pull_request) Successful in 40s
Check / check (pull_request) Has been cancelled
to 75116b3d71
Some checks failed
Build Images / build (pull_request) Successful in 39s
Check / check (pull_request) Has been cancelled
2026-09-27 00:45:40 +03:00
Compare
repomaa scheduled this pull request to auto merge when all checks succeed 2026-09-27 00:45:49 +03:00
repomaa force-pushed ci-deploy-trigger from 75116b3d71
Some checks failed
Build Images / build (pull_request) Successful in 39s
Check / check (pull_request) Has been cancelled
to 5bf950860f
All checks were successful
Build Images / build (pull_request) Successful in 39s
Check / check (pull_request) Successful in 4m4s
2026-09-27 00:46:44 +03:00
Compare
repomaa scheduled this pull request to auto merge when all checks succeed 2026-09-27 00:47:04 +03:00
repomaa deleted branch ci-deploy-trigger 2026-09-27 00:57:32 +03:00
hermes referenced this pull request from a commit 2026-09-27 22:31:19 +03:00
repomaa referenced this pull request from a commit 2026-09-27 22:48:54 +03:00
repomaa referenced this pull request from a commit 2026-09-27 22:56:27 +03:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
repomaa/nixos!11
No description provided.