You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(installer): use a path: flake so the host stays gitignored
The generated per-host dir (hosts/<host>/) is gitignored because it holds
secrets (install-answers.json, local.nix). A git flake only sees tracked
files, so install.sh force-added the host with `git add --intent-to-add -f`
just to make Nix see it — which staged those secrets and left the tree
permanently dirty.
Reference the repo as a `path:` flake instead, which copies the directory
verbatim (gitignored files included), and drop the intent-add entirely. The
host is now truly untracked: never staged, never in `git status`, secrets
never enter the index. All install-time and on-box flake commands
(nix eval/build, disko, nixos-install, coder-reset's nixos-rebuild) use
path:/… refs.
Also make the installed /etc/nixos-repo usable as a normal git checkout:
chown root:wheel + group-writable so wheel users `git pull` / edit without
sudo, and check out a `main` branch tracking origin (a baked image .git is a
detached, branchless CI checkout, so `git pull` had no branch to pull).
Docs (README, agents.md, hosts/incus-vm/README) updated for the path: rebuild
command and the writable, branch-tracking repo; removed the stale
intent-to-add / dirty-tree guidance.
Copy file name to clipboardExpand all lines: README.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,12 @@ NixOS configuration for Coder demo and workshop boxes.
20
20
This repo is a Nix flake. `flake.nix` auto-discovers every subdirectory of
21
21
`./hosts/` that contains a `default.nix` and exposes it as
22
22
`nixosConfigurations.<folder-name>`. For normal install hosts the folder name
23
-
is also the hostname, so `nixos-rebuild switch --flake .` auto-selects the
24
-
right config on the running box. Adding a new host means creating a host
25
-
folder, no flake.nix edit. The installer does this for you.
23
+
is also the hostname, so `nixos-rebuild switch --flake path:/etc/nixos-repo`
24
+
auto-selects the right config on the running box. Adding a new host means
25
+
creating a host folder, no flake.nix edit. The installer does this for you.
26
+
(The per-host dir is gitignored, so the box uses a `path:` flake ref — which
27
+
copies the tree verbatim, gitignored files included — rather than a git flake,
28
+
which would only see tracked files. See [Applying changes](#applying-changes).)
26
29
27
30
Hosts whose folder name starts with an underscore (`_appliance-iso`,
28
31
`_appliance-disk`, `_installer-iso`) are image builds, not per-machine installs: they
@@ -61,7 +64,7 @@ sudo ./install.sh \
61
64
62
65
`./install.sh --help` lists everything. `--coder-admin-password-file PATH` and `--nixos-password-file PATH` read passwords from a file so they don't end up in shell history. `--no-reboot` skips the automatic reboot at the end.
63
66
64
-
The installer generates `hosts/<hostname>/{default.nix,local.nix,install-answers.json,facter.json}`, copies the repo into `/etc/nixos-repo` on the target, and symlinks `/etc/nixos/flake.nix`. After reboot, `nixos-rebuild switch` Just Works. Continue with [After install](#after-install).
67
+
The installer generates `hosts/<hostname>/{default.nix,local.nix,install-answers.json,facter.json}`, copies the repo into `/etc/nixos-repo` on the target (owned `root:wheel` and checked out on `main`, so wheel users can `git pull` / edit it without sudo), and symlinks `/etc/nixos/flake.nix`. Rebuild with `sudo nixos-rebuild switch --flake path:/etc/nixos-repo`. Continue with [After install](#after-install).
65
68
66
69
> **Different partition layout?** Don't import `installer/bootstrap/disko-standard.nix`; drop your own disko config into the host folder instead. See [disko examples](https://github.com/nix-community/disko/tree/master/example).
67
70
@@ -196,26 +199,24 @@ boot via `coder-init-admin.service`. After the reboot:
196
199
defaults.
197
200
198
201
Subsequent edits to `coderd/` templates go out via `coder-template-sync`
199
-
on every `sudo nixos-rebuild switch`.
202
+
on every `sudo nixos-rebuild switch --flake path:/etc/nixos-repo`.
200
203
201
204
## Applying changes
202
205
206
+
The per-host dir (`hosts/<host>/`) is gitignored and stays untracked, so the
207
+
box uses a `path:` flake ref (a plain git flake would not see it). The repo is
208
+
owned `root:wheel`, so wheel users edit it and `git pull` without sudo.
209
+
203
210
```sh
204
-
sudo nixos-rebuild switch # most changes
205
-
sudo nixos-rebuild boot && sudo reboot # changes that touch the desktop stack
206
-
207
-
# Edited hosts/<host>/local.nix, install-answers.json, or facter.json? Re-mark intent-to-add:
The repo is baked onto the box at **`/etc/nixos-repo`** (the canonical flake;
37
37
`nixosConfigurations.<hostname>`, auto-selected by the running hostname). Edit
38
-
files there, then rebuild. Always pass `--flake /etc/nixos-repo` (or `cd` into
39
-
it and use `--flake .`) — see the `/etc/nixos` pitfall below.
38
+
files there, then rebuild. Always pass `--flake path:/etc/nixos-repo`. The
39
+
per-host dir (`hosts/<host>/`) is gitignored and untracked, so a `path:` flake
40
+
ref is required — a plain git flake (`--flake /etc/nixos-repo` or `--flake .`)
41
+
only sees tracked files and would not find the host. See the `/etc/nixos`
42
+
pitfall below.
40
43
41
44
`nixos-rebuild switch` triggers the `coder-template-sync` activation script, which runs `terraform apply` in `coderd/` and pushes any template changes to Coder. The `/etc/coder/session-token` it needs is populated automatically by `coder-init-admin.service` on first boot, so this just works post-install.
42
45
@@ -73,13 +76,14 @@ if something is off. Run `make fmt` to fix formatting locally.
73
76
74
77
## Git Workflow
75
78
76
-
All files in `/etc/nixos-repo/` are root-owned. Use `sudo git`:
79
+
All files in `/etc/nixos-repo/` are owned `root:wheel` and group-writable, so
-**Tailscale auth doesn't re-run** — `tailscale-autoauth` has `RemainAfterExit = true`. If you change auth key config, run `sudo systemctl restart tailscale-autoauth`.
198
202
-**Template sync skips**, if `/etc/coder/session-token` is empty, the activation script exits cleanly. The token is auto-populated by `coder-init-admin.service`; if it's missing, check `journalctl -u coder-init-admin`.
199
203
-**`coder` binary path** — the binary is in PATH via NixOS environment; don't hardcode nix store paths in scripts (they change with every package update).
200
-
-**`--flake /etc/nixos` fails** — `/etc/nixos` is a plain dir holding only a `flake.nix`*symlink* into `/etc/nixos-repo`. Nix follows the symlink into the store but can't find the sibling files (configuration.nix, hosts/, nixos/), dying with `path '/nix/store/...-source/etc/nixos-repo/flake.nix' does not exist`. Always rebuild against the real tree: `--flake /etc/nixos-repo` (or `cd /etc/nixos-repo && nixos-rebuild switch --flake .`).
201
-
-**`Git tree '/etc/nixos-repo' is dirty` warning** — harmless. `hosts/<host>/{local.nix,install-answers.json,facter.json}` are gitignored and intent-to-added by the installer, so the tree always reads "dirty". After editing them, re-mark intent-to-add so the flake sees them: `sudo git -C /etc/nixos-repo add --intent-to-add -f hosts/<host>/local.nix hosts/<host>/install-answers.json hosts/<host>/facter.json`.
204
+
-**`--flake /etc/nixos` fails** — `/etc/nixos` is a plain dir holding only a `flake.nix`*symlink* into `/etc/nixos-repo`. Nix follows the symlink into the store but can't find the sibling files (configuration.nix, hosts/, nixos/), dying with `path '/nix/store/...-source/etc/nixos-repo/flake.nix' does not exist`. Always rebuild against the real tree with a `path:` ref: `--flake path:/etc/nixos-repo`.
205
+
-**Host not found / `does not provide attribute 'nixosConfigurations.<host>'`** — the per-host dir is gitignored and untracked, so a git flake (`--flake /etc/nixos-repo` or `--flake .`) can't see it. Use `--flake path:/etc/nixos-repo`, which copies the tree verbatim (gitignored files included). This is also why nothing intent-adds the host and `git status` stays clean.
202
206
-**ScreenConnect blank screen** — the box now runs GNOME on Wayland (GDM), and GNOME 49 dropped the Xorg session, so there is no X11 desktop to fall back to. ScreenConnect reaches `DISPLAY=:0` through XWayland (see `nixos/screenconnect.nix`) but **cannot screen-capture the Wayland compositor** through it, so the remote view may be black/blank. Capturing the GNOME session needs a Wayland-aware path (PipeWire/portal, e.g. `gnome-remote-desktop`); the X11 agent will connect but not mirror the desktop.
0 commit comments