Same class of problem as the deployedTargets/README fixes: hand-maintained prose that drifted from reality and nobody was obligated to update. - CLAUDE.md: "18 hosts" was a stale hardcoded count (actually 20); reworded to not need updating as hosts are added. Also added the missing tailscale-exit-node build type to a list that had it everywhere else in the file except one bullet. - AGENTS.md: same missing tailscale-exit-node build type. - docs/auto-installer.md: the hand-enumerated lxc-* list was missing lxc-tailscale-exit-node. - flake-target-refactor-spec.md: added a "Status: implemented" note so this completed historical spec (referenced elsewhere purely for rationale) can't be mistaken for an open plan with unresolved Open Questions. - remove-sensetive-info-refactor.md: the "Definition of done" checklist was entirely unchecked despite most of the work being done. Checked off what's actually done (sops-nix migration, history scrub just performed, the pre-commit gitleaks hook), and left rotation of the GitHub PAT found in history explicitly flagged as the one still-open item -- an operator action against GitHub, not something this repo can attest to itself. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
7.1 KiB
Executable File
Spec: Refactor Flake Targets into Platform × Build-Type Matrix
Status: implemented. flake.nix's generatedTargets/mkTarget and
modules/platforms/*/modules/build-types/* are the result of this spec —
kept here for historical rationale only (referenced from CLAUDE.md's
"Composition pattern" section), not as an active or open plan. The "Open
Questions" below were resolved during implementation; don't treat them as
outstanding. A tailscale-exit-node build type was added later, beyond this
spec's original scope.
Context
The flake at ~/nixos currently defines these output targets (flat, ad-hoc naming):
dockerlinode-minimalnix-cachenix-minimalnixosserverpxe-boot
Some already follow a platform-buildtype convention (linode-minimal), most don't.
~/nix-auto-installer is a related repo and should be checked for any coupling to
these target names (scripts, docs, CI, or install automation that reference them by
name) before renaming anything.
Goal
Restructure the flake so targets are generated from two orthogonal concepts:
Build types (what the system is for):
minimalnix-cacheserverdockerpxe-bootgui
Platforms (what it's deployed on):
linode(Linode VM)proxmox(Proxmox VM)lxc(Proxmox LXC container)
Final targets should be named consistently as <platform>-<buildtype>, e.g.:
linode-minimal proxmox-minimal lxc-minimal
linode-nix-cache proxmox-nix-cache lxc-nix-cache
linode-server proxmox-server lxc-server
linode-docker proxmox-docker lxc-docker
linode-pxe-boot proxmox-pxe-boot lxc-pxe-boot
linode-gui proxmox-gui lxc-gui
That's the full matrix (18 targets) if every build type applies to every platform. See Open Questions below — some combinations may not make sense and should be confirmed with me before being built out, not silently included or dropped.
Migration mapping (old → new)
| Old target | New target | Notes |
|---|---|---|
linode-minimal |
linode-minimal |
Already correct, keep as-is |
nix-minimal |
likely proxmox-minimal or a platform-less base module |
Ambiguous — see Open Questions |
nix-cache |
base module consumed by linode-nix-cache, proxmox-nix-cache, lxc-nix-cache |
Currently platform-less; needs to become a build-type module, not a standalone target |
server |
base module consumed by linode-server, proxmox-server, lxc-server |
Same as above |
docker |
base module consumed by linode-docker, proxmox-docker, lxc-docker |
Confirm docker actually makes sense as an LXC/VM guest build vs. a standalone container image — see Open Questions |
pxe-boot |
TBD — may stay a single target rather than a per-platform one | See Open Questions |
nixos |
TBD — unclear what this maps to in the new scheme | See Open Questions |
Open Questions (Claude Code: raise these with me before implementing, don't guess)
nixostarget — what is this currently used for (bare metal install, dev shell, template)? It doesn't obviously map to any of the six build types.nix-minimalvslinode-minimal— are these two different things, or isnix-minimala leftover/duplicate?pxe-bootandguiacross all three platforms — does PXE boot make sense for an LXC container or a cloud VM (Linode), or is it inherently bare-metal/ network-boot only and should remain a single non-platform target? Doesguimake sense inside an LXC container?dockeras a build type — is this "a NixOS host configured to run Docker" (which would sensibly have linode/proxmox/lxc variants), or "a Docker container image built by the flake" (which wouldn't take a platform prefix at all, since it doesn't run on Linode/Proxmox/LXC as a guest OS)? These are structurally different and change how it should be wired in.- Confirm whether all 18 combinations should actually exist, or whether this is
meant to produce only the combinations that are genuinely useful (e.g. maybe no
one needs
lxc-pxe-boot).
Implementation approach
- Inventory first. Read the current
flake.nixand anynixosConfigurations/modulesstructure. Map every existing target to what module(s) it actually pulls in. Don't assume — confirm against the real file contents. - Separate build-type and platform into their own module directories, e.g.:
Build-type modules should contain only what makes a system "minimal" vs "server" vs "gui", etc. Platform modules should contain only what's specific to running as a Linode VM vs Proxmox VM vs LXC container (virtualisation guest tools, boot method, filesystem/image format, LXC-specific constraints like no kernel modules, etc).
modules/build-types/minimal.nix modules/build-types/nix-cache.nix modules/build-types/server.nix modules/build-types/docker.nix modules/build-types/pxe-boot.nix modules/build-types/gui.nix modules/platforms/linode.nix modules/platforms/proxmox.nix modules/platforms/lxc.nix - Generate the target matrix programmatically in
flake.nixrather than hand-writing 18 near-identicalnixosConfigurationsentries — e.g. a small function that takes a platform name and build-type name, composes the two modules plus any shared base module, and produces the named output. This keeps future build types/platforms a one-line addition rather than a copy-paste job. - Only build combinations we've confirmed make sense (see Open Questions) — don't emit all 18 by default if some are structurally invalid.
- Preserve existing working configs during the transition. Don't delete the old target names until their replacements build successfully — rename/alias at the end, not the start, so there's no window where the flake is broken.
Verification
For every new target produced:
nix flake check
nix build .#nixosConfigurations.<target>.config.system.build.toplevel
Confirm each builds without evaluation errors before considering it done. If a target fails to build, report which one and why rather than silently skipping it.
Deliverables
- Refactored
flake.nixusing the composed module + generated-matrix approach. - New
modules/build-types/*.nixandmodules/platforms/*.nixfiles. - Old flat target names removed only after their replacements are verified.
- A short
README.md(or section in existing docs) listing the final target names and what each one is for. - A summary at the end of what changed, what was removed, and any of the Open Questions above that got resolved differently than expected.
Out of scope
- Don't touch
~/nix-auto-installercontents beyond checking it for references to the old target names — if changes there are needed, flag them, don't make them without confirming. - Don't add new build types or platforms beyond the ones listed here.