| name | add-nixos-host |
| description | Create a new NixOS host configuration in this repository |
| license | MIT |
| metadata | {"audience":"nixos-admins","workflow":"host-creation"} |
What I do
Create a complete new host configuration for this NixOS flake repository including:
- Host directory structure (
hosts/host.<hostname>/)
default.nix with boilerplate configuration
hardware-configuration.nix template
- Update
flake.nix: add nixosConfigurationsGen.host-<name> generator and nixosConfigurations.<name> entry
- Update
hosts/metadata.json: add host metadata entry
- Set up network and WireGuard configuration (optional)
When to use me
Use this when adding a new NixOS host to your configuration repository. I'll guide you through gathering all necessary information and create the appropriate files with proper formatting.
Questions I'll ask
- Hostname - lowercase alphanumeric name (e.g.,
newhost)
- System architecture -
x86_64-linux or aarch64-linux
- Host template - Choose existing host to base configuration on:
f13 (laptop, desktop, wayland, full-featured)
pi4 (headless ARM, minimal, containerized)
spare (laptop, build slave, minimal desktop)
workstation (desktop, gaming, AMD/NVIDIA)
nas (server, headless, storage)
- Network configuration
- Network name:
home
- Use DHCP or static IP?
- If static: IP address (e.g.,
192.168.1.X)
- WireGuard - Enable WireGuard VPN?
- If yes: WG IP (e.g.,
10.199.199.X)
- SSH keys - Generate placeholder or reference existing host?
Implementation steps
- Validate hostname format (lowercase alphanumeric, no special chars)
- Read
hosts/metadata.json to check for duplicates
- Create host directory:
hosts/host.<hostname>/
- Generate
default.nix based on selected template
- Generate
hardware-configuration.nix template (placeholder for actual hardware scan)
- Add to
flake.nix:
- Generator entry in
nixosConfigurationsGen
- Configuration entry in
nixosConfigurations
- Update
hosts/metadata.json with host metadata
- Run
./nixfmtall.sh to format all changes
- Validate with
nix flake check
- Add new files to git:
git add hosts/host.<hostname>/ flake.nix hosts/metadata.json
Notes
- The
hardware-configuration.nix will be a template; run sudo nixos-generate-config on the actual host to generate the real hardware configuration
- Host configurations follow the pattern:
evalConfiguration "<system>" "<hostname>" [ self.nixosModules.core ] ++ moreModules { }
- New hosts with
announceOtherHosts will be discoverable by other hosts in the network
- WireGuard IPs should be from the
10.199.199.0/24 subnet