aboutsummaryrefslogtreecommitdiffstats
path: root/openspec/changes/add-host-bootstrap-script/specs
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2026-09-17 11:05:45 +0200
committerGravatar Tom van der Lee <tom@vanderlee.io>2026-09-17 11:05:45 +0200
commitf793f76e26b461c3228c69926d82bf950aaac671 (patch)
treeaffac98593ff0de3bb24fcd8aa64f6ef8ed9dc19 /openspec/changes/add-host-bootstrap-script/specs
parentae3fa667bda75f11881c9209dc67226f98bcfd95 (diff)
downloaddesktop-flake-f793f76e26b461c3228c69926d82bf950aaac671.tar.gz
desktop-flake-f793f76e26b461c3228c69926d82bf950aaac671.tar.bz2
desktop-flake-f793f76e26b461c3228c69926d82bf950aaac671.zip
Add scripted host bootstrapping with directory-driven discovery
nixosConfigurations now auto-discovers hosts/<name>/ directories instead of a hand-maintained attrset, and scripts/bootstrap-host.sh (exposed as `nix run .#bootstrap-host`) scaffolds a new host from the template. The script always requires an explicit --root for hardware-configuration.nix so a live-installer run can never read the live ISO's own /etc/nixos by accident. Also records the belated task-11.1 checkbox update for the prior change's already-committed state.
Diffstat (limited to 'openspec/changes/add-host-bootstrap-script/specs')
-rw-r--r--openspec/changes/add-host-bootstrap-script/specs/nix-flake-bootstrap/spec.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/openspec/changes/add-host-bootstrap-script/specs/nix-flake-bootstrap/spec.md b/openspec/changes/add-host-bootstrap-script/specs/nix-flake-bootstrap/spec.md
new file mode 100644
index 0000000..3203b99
--- /dev/null
+++ b/openspec/changes/add-host-bootstrap-script/specs/nix-flake-bootstrap/spec.md
@@ -0,0 +1,49 @@
1## Purpose
2
3Provides a single Nix flake that provisions NixOS hosts from a copyable template and provisions a shared, cross-platform home-manager user profile that installs standalone on non-NixOS systems, keeping both paths built from the same per-user module.
4
5## ADDED Requirements
6
7### Requirement: Host directories are auto-discovered as flake outputs
8Any directory under `hosts/` other than `hosts/template` that contains a valid host definition SHALL automatically become a `nixosConfigurations.<name>` output, without requiring any edit to `flake.nix`.
9
10#### Scenario: New host directory becomes buildable without touching flake.nix
11- **WHEN** a new directory `hosts/<name>/` is created containing `configuration.nix`, `hardware-configuration.nix`, and a `system` file, and `flake.nix` itself is left unmodified
12- **THEN** `nixosConfigurations.<name>` evaluates successfully as part of the flake's outputs
13
14#### Scenario: Template remains excluded from discovery
15- **WHEN** the flake's outputs are evaluated
16- **THEN** `hosts/template` does not appear as a `nixosConfigurations` entry, regardless of its contents
17
18### Requirement: Host creation is scripted
19The system SHALL provide a script that scaffolds a new NixOS host directory from the template, given a hostname, a target root path, and a state version.
20
21#### Scenario: Scaffolding a new host
22- **WHEN** the host creation script is run with a hostname, a `--root` path, and a `--state-version`
23- **THEN** a `hosts/<hostname>/` directory is created containing a `configuration.nix` with the hostname and state version filled in, a `system` file, and a `hardware-configuration.nix` copied from the given root
24
25#### Scenario: Refusing to overwrite an existing host
26- **WHEN** the host creation script is run with a hostname that already has a `hosts/<hostname>/` directory, without an explicit override flag
27- **THEN** the script fails without modifying the existing directory
28
29### Requirement: Hardware configuration source is always explicit
30The host creation script SHALL require an explicit root path for locating `hardware-configuration.nix` and SHALL NOT read from the invoking system's own `/etc/nixos` unless that path is explicitly given as the root.
31
32#### Scenario: No root provided
33- **WHEN** the host creation script is run without a root path specified
34- **THEN** the script fails with an error rather than falling back to any default location
35
36#### Scenario: Live installer environment targets the mounted install, not the live system
37- **WHEN** the host creation script is run from a NixOS live/installer environment with `--root /mnt` pointing at a freshly mounted install target
38- **THEN** the resulting `hardware-configuration.nix` is copied from `/mnt/etc/nixos/hardware-configuration.nix`, and the live environment's own `/etc/nixos/hardware-configuration.nix` is never read
39
40#### Scenario: Hardware configuration cannot be found or generated
41- **WHEN** the host creation script is run with a `--root` path that has no `hardware-configuration.nix` and no `nixos-generate-config` command is available to create one
42- **THEN** the script fails with a clear error instead of proceeding with a missing or stub file
43
44### Requirement: Install target matches the created host name
45The host attribute produced for a newly scaffolded host SHALL exactly match the hostname given to the creation script, so the host can be installed or rebuilt via `<flake>#<hostname>`.
46
47#### Scenario: Installing a newly scaffolded host
48- **WHEN** a host is scaffolded with a given hostname
49- **THEN** `nixos-install --flake <flake-path>#<hostname>` and `nixos-rebuild switch --flake <flake-path>#<hostname>` both resolve to the configuration that was just scaffolded