|
489 | 489 | programs.git.config.safe.directory = [ "/etc/nixos-repo" ]; |
490 | 490 |
|
491 | 491 | # ── Coder server ────────────────────────────────────────────────────────── |
492 | | - # Base env vars live here. Secrets (admin creds, OAuth, etc.) are merged in |
493 | | - # via systemd.services.coder.environment in hosts/<host>/local.nix; no EnvironmentFile. |
| 492 | + # Base env vars live here. Server secrets (e.g. OAuth) are merged in via |
| 493 | + # systemd.services.coder.environment in hosts/<host>/local.nix; no |
| 494 | + # EnvironmentFile. Admin bootstrap creds (CODER_ADMIN_*) are NOT set here — |
| 495 | + # they live on coder-init-admin.service so they stay off the long-running |
| 496 | + # server's environment. |
494 | 497 | systemd.services.coder = { |
495 | 498 | description = "Coder Server"; |
496 | 499 | wantedBy = [ "multi-user.target" ]; |
|
538 | 541 | }; |
539 | 542 |
|
540 | 543 | # ── Admin user bootstrap ────────────────────────────────────────────────── |
541 | | - # Reads CODER_ADMIN_* from coder.service environment (set via local.nix). |
| 544 | + # Reads CODER_ADMIN_* from this service's own environment (set via |
| 545 | + # local.nix as systemd.services.coder-init-admin.environment), keeping the |
| 546 | + # admin credentials off the long-running coder.service. |
542 | 547 | # Creates a local admin account once; sentinel prevents re-running. |
543 | 548 | # If CODER_ADMIN_EMAIL is unset, skips and directs user to the browser wizard. |
544 | 549 | systemd.services.coder-init-admin = { |
|
547 | 552 | after = [ "coder.service" ]; |
548 | 553 | requires = [ "coder.service" ]; |
549 | 554 |
|
550 | | - # Inherit the full coder.service environment so CODER_ADMIN_* and |
551 | | - # CODER_PG_CONNECTION_URL are available without duplication. |
| 555 | + # Inherit the coder.service environment so CODER_PG_CONNECTION_URL (and the |
| 556 | + # other server vars) are available without duplication. The CODER_ADMIN_* |
| 557 | + # credentials are merged in on top via the coder-init-admin.environment |
| 558 | + # definition in hosts/<host>/local.nix (NixOS merges attrset options). |
552 | 559 | inherit (config.systemd.services.coder) environment; |
553 | 560 |
|
554 | 561 | serviceConfig = { |
|
687 | 694 | ]; |
688 | 695 | requires = [ "postgresql.service" ]; |
689 | 696 |
|
690 | | - inherit (config.systemd.services.coder) environment; |
| 697 | + # Step 8 mints a session token using CODER_ADMIN_EMAIL/PASSWORD, so pull in |
| 698 | + # the coder-init-admin environment (which itself includes the coder.service |
| 699 | + # vars plus the CODER_ADMIN_* credentials from local.nix). |
| 700 | + inherit (config.systemd.services.coder-init-admin) environment; |
691 | 701 |
|
692 | 702 | serviceConfig = { |
693 | 703 | Type = "oneshot"; |
|
0 commit comments