refactor(installer): path: flake so the installed host stays gitignored + writable repo - #78
Draft
phorcys420 wants to merge 1 commit into
Draft
refactor(installer): path: flake so the installed host stays gitignored + writable repo#78phorcys420 wants to merge 1 commit into
phorcys420 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the installed box's
/etc/nixos-repobehave like a normal, user-editable git checkout, and stop staging per-host secrets into the git index.Problems
hosts/<host>/is gitignored (it holdsinstall-answers.jsonandlocal.nix). A git flake only sees tracked/staged files, soinstall.shforce-added the host withgit add --intent-to-add -fpurely so Nix could find it — which staged the secrets and left the tree permanently dirty.git pull/ edits neededsudo..gitis a detached, branchless CI checkout, sogit pullon the box failed with "not currently on a branch".Change
Reference the repo as a
path:flake (path:/etc/nixos-repo) instead of a git flake. Apath:flake copies the directory verbatim — gitignored files included — so the host is visible without any staging. Thegit add --intent-to-add -fis removed entirely; the host dir is now truly untracked (never staged, never ingit status, secrets never enter the index).All install-time and on-box flake commands use
path:refs:nix eval/nix build,disko --flake,nixos-install --flake, andcoder-reset'snixos-rebuild switch.Installed repo is now a usable checkout: after copying,
install.shdoeschown -R root:wheel+chmod -R g+wso wheel usersgit pull/ edit without sudo, and checks out amainbranch trackingoriginsogit pullworks out of the box.Rebuild command is now
sudo nixos-rebuild switch --flake path:/etc/nixos-repo. Docs (README,agents.md,hosts/incus-vm/README) updated; the stale intent-to-add / "tree is dirty" guidance is removed.Why
path:over keeping a git flakeA strict git flake can't see an untracked host, so the only alternatives were committing secrets (no) or intent-adding them (the staging problem). The other way to keep a git flake is to move secrets out of the repo and import them by absolute path under
--impure— more invasive, less reproducible, and it changes host discovery.path:is the smallest change that keeps thehosts/<hostname>/layout, keeps the host gitignored, and letsgit pullwork normally. Tradeoff:path:ignores.gitignoreand copies the whole dir (incl..git) each eval — negligible on the box.Validation
Proved the mechanism on a truly untracked, gitignored host (no intent-add):
git statusshows the host dir nowhere (fully ignored, unstaged).shellcheck/shfmt/bash -nclean oninstall.sh;nix fmtclean.nixos-rebuildwas run anywhere; validation isnix evalonly.Generated by Coder Agents on behalf of @phorcys420.