Machine folder, layout and migration
Each host has its own usr/machines/<hôte>/ folder. Files there are organised by who writes them : you, the installation, the machine itself or the generator. The framework imports them one by one, there is no default.nix.
Layout
Section titled “Layout”usr/machines/<hôte>/ configuration.nix # vous : seul fichier à éditer <autres>.nix # vous : importés depuis configuration.nix install/ disko.nix # disposition du disque, figée à l'installation state.nix # system.stateVersion, figé à l'installation hardware/ hardware-configuration.nix # relevé sur la machine detected-hardware.nix # pilotes réseau relevés (just detect-hw)
var/generated/hosts/<hôte>.nix # drapeaux de démarrage déduits du disque| File | Written by | Rewritten | If lost |
|---|---|---|---|
configuration.nix | you (seeded by just generate) | never | work lost |
install/disko.nix | just generate (profile and devices) | as long as the host is not installed | actual disk layout unknown |
install/state.nix | just install, just install-key | never | inconsistent service data |
hardware/ | just install, copy-hw, detect-hw | on each capture | recapture needed on the machine |
var/generated/hosts/<hôte>.nix | just generate | on each generation | nothing, it is recomputed |
var/generated/hosts/<hôte>.nix only exists if the disk requires boot settings (software RAID, NEEDEDFORBOOT markers).
The installation seal
Section titled “The installation seal”install/state.nix seals the host. just install writes it just before formatting, with the current nixpkgs release (the value nixos-generate-config would write).
- Before:
install/disko.nixfollowsetc/config.yamlon eachjust generate. - After:
install/disko.nixno longer changes. Thediskoblock inetc/config.yamlhas no more effect.
| Need | Action |
|---|---|
| Reinstall identically (restore, databases) | do nothing |
| Change disk while keeping data | delete install/disko.nix, then just generate |
| Start from a like-new machine, without recovery | delete install/state.nix |
Migrating from the old layout
Section titled “Migrating from the old layout”Breaking change : the old layout (default.nix imported as entry point) is no longer read.
| Old | New |
|---|---|
default.nix | configuration.nix, without imports or stateVersion |
system.stateVersion from default.nix | install/state.nix |
disko.nix | install/disko.nix |
hardware-configuration.nix | hardware/hardware-configuration.nix |
detected-hardware.nix | hardware/detected-hardware.nix |
generated-configuration.nix | var/generated/hosts/<hôte>.nix, generated |
-
Find the forced devices in the old
generated-configuration.nix(disko.devices.disk.<disque>.device = lib.mkForce "…"lines). They are no longer generated. -
Move the files
Fenêtre de terminal cd usr/machines/<hôte>mkdir -p install hardwaregit mv disko.nix install/disko.nixgit mv hardware-configuration.nix hardware/ # si présentgit mv detected-hardware.nix hardware/ # si présentgit mv default.nix configuration.nixgit rm generated-configuration.nix -
Port the devices found in step 1 to
install/disko.nix, when they differ from thedevicevalue in the file. -
Create
install/state.nixwith the exact value of the oldsystem.stateVersion:# usr/machines/<hôte>/install/state.nix{ system.stateVersion = "25.11"; } -
Lighten
configuration.nix: remove the imports ofnot-detected.nix,generated-configuration.nix,hardware-configuration.nix,disko.nix,detected-hardware.nixand thesystem.stateVersionline. Keep everything else. -
Regenerate and commit
Fenêtre de terminal just cleangit add usr/machines var/generated