Adding A New Machine

This page is the operational checklist for adding a NixOS host to the flake.

For why flakes, modules, and Home Manager work this way, see Nix Concepts.

Naming

Pick two names before creating files:

NameExampleUsed for
Directoryframework, x1Human-readable folder under conf/machines/.
Hostnamehaxorusnetworking.hostName and flake target.

They may match, but they do not have to.

Existing hosts use short hardware directory names and Pokemon hostnames.

Checklist

StepFile or commandNotes
Generate hardware confignixos-generate-config --show-hardware-configStore it in the new host directory.
Add host moduleconf/machines/{machine}/configuration.nixImport hardware and shared NixOS config.
Set hostnamenetworking.hostName = "{hostname}";Must match the flake target you plan to build.
Add flake outputnixosConfigurations.{hostname}Copy the shape of existing hosts.
Choose architecturex86_64-linux or aarch64-linuxMatch the target CPU.
Build temporarilysudo nixos-rebuild test --flake .#{hostname}Safer first activation.
Make persistentsudo nixos-rebuild switch --flake .#{hostname}Only after the test generation works.

Host Directory

Create:

conf/machines/{machine}/
├── configuration.nix
└── hardware-configuration.nix

hardware-configuration.nix should stay mostly generated. It captures machine facts: filesystems, swap, kernel modules, CPU hints, and hardware-specific imports.

configuration.nix should contain host choices: hostname, hardware workarounds, desktop stack imports, power management, and services that belong only on that machine.

Keep general packages, users, shell defaults, editor defaults, and shared secrets in conf/shared.nix.

Minimal Host Module

{ ... }:

{
  imports = [
    ./hardware-configuration.nix
    (import ../../shared.nix).nixos
  ];

  networking.hostName = "{hostname}";
}

For a host-specific desktop stack, import its system module here. nix-haxorus does this for Hyprland.

Flake Output

Add a nixosConfigurations.{hostname} entry in flake.nix. Copy an existing host entry and adjust:

  • output name
  • system
  • machine configuration path
  • any host-specific Home Manager imports

This repo wires Home Manager through each NixOS system, so normal nixos-rebuild applies both system and user changes.

Activation

Build and activate temporarily:

sudo nixos-rebuild test --flake .#{hostname}

If it works, make it the boot default:

sudo nixos-rebuild switch --flake .#{hostname}

If a switched generation is bad:

sudo nixos-rebuild switch --rollback

Final Review

  • Hardware config is present and machine-specific.
  • Host module imports shared NixOS config.
  • Hostname and flake output name match.
  • Architecture matches the machine.
  • Host-only features stayed out of conf/shared.nix.
  • Shared behavior went into conf/shared.nix.
  • test succeeded before switch.