Skip to content

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.

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
FileWritten byRewrittenIf lost
configuration.nixyou (seeded by just generate)neverwork lost
install/disko.nixjust generate (profile and devices)as long as the host is not installedactual disk layout unknown
install/state.nixjust install, just install-keyneverinconsistent service data
hardware/just install, copy-hw, detect-hwon each capturerecapture needed on the machine
var/generated/hosts/<hôte>.nixjust generateon each generationnothing, it is recomputed

var/generated/hosts/<hôte>.nix only exists if the disk requires boot settings (software RAID, NEEDEDFORBOOT markers).

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.nix follows etc/config.yaml on each just generate.
  • After: install/disko.nix no longer changes. The disko block in etc/config.yaml has no more effect.
NeedAction
Reinstall identically (restore, databases)do nothing
Change disk while keeping datadelete install/disko.nix, then just generate
Start from a like-new machine, without recoverydelete install/state.nix

Breaking change : the old layout (default.nix imported as entry point) is no longer read.

OldNew
default.nixconfiguration.nix, without imports or stateVersion
system.stateVersion from default.nixinstall/state.nix
disko.nixinstall/disko.nix
hardware-configuration.nixhardware/hardware-configuration.nix
detected-hardware.nixhardware/detected-hardware.nix
generated-configuration.nixvar/generated/hosts/<hôte>.nix, generated
  1. Find the forced devices in the old generated-configuration.nix (disko.devices.disk.<disque>.device = lib.mkForce "…" lines). They are no longer generated.

  2. Move the files

    Fenêtre de terminal
    cd usr/machines/<hôte>
    mkdir -p install hardware
    git mv disko.nix install/disko.nix
    git mv hardware-configuration.nix hardware/ # si présent
    git mv detected-hardware.nix hardware/ # si présent
    git mv default.nix configuration.nix
    git rm generated-configuration.nix
  3. Port the devices found in step 1 to install/disko.nix, when they differ from the device value in the file.

  4. Create install/state.nix with the exact value of the old system.stateVersion :

    # usr/machines/<hôte>/install/state.nix
    { system.stateVersion = "25.11"; }
  5. Lighten configuration.nix : remove the imports of not-detected.nix, generated-configuration.nix, hardware-configuration.nix, disko.nix, detected-hardware.nix and the system.stateVersion line. Keep everything else.

  6. Regenerate and commit

    Fenêtre de terminal
    just clean
    git add usr/machines var/generated