Nix Auto Installer
This repository builds a custom NixOS installer environment that can automatically install any host exposed by a separate NixOS flake.
The installer provides a small NixOS netboot/install environment with SSH access,
Git support, and an interactive installation script. When the nixos user logs
in, it runs /etc/auto-install.sh, discovers available hosts from the target
flake, allows the operator to choose a system profile, applies the matching
Disko storage configuration, installs NixOS, and reboots.
The installer is designed for a mixed environment where different machines may have different storage layouts, including Proxmox VMs, Linode instances, and physical hardware. Disk layout is no longer hardcoded in the installer; it is defined by each host's NixOS configuration using Disko.
Repository Layout
-
flake.nix- Defines the installer build outputs.
- Builds an
install-isoimage usingnixos-generators. - Builds netboot kernel, initrd, and iPXE scripts.
-
installer.nix- Defines the installer environment.
- Enables SSH access.
- Configures Git access to the target flake repository.
- Creates the
nixosandrootusers. - Provides the generated
/etc/auto-install.shinstallation script.
The installed system configuration lives in a separate NixOS flake. Each target host is exposed through:
nixosConfigurations.<hostname>
and may optionally include a Disko storage configuration.
Requirements
The build machine requires:
- Nix installed with flakes enabled.
- Network access to fetch flake inputs.
- Ability to build NixOS images.
The target machine requires:
- Network connectivity during installation.
- A disk defined by its Disko configuration.
- SSH access or local console access.
Build The Installer ISO
From the repository root:
nix build
The generated installer ISO will be available through the result symlink.
The ISO is generated using:
nixos-generators.nixosGenerate {
format = "install-iso";
}
Build Netboot Components
The flake also exposes netboot components:
nix build .#netboot-ipxe
nix build .#netboot-initrd
nix build .#netboot-kernel
These can be used to PXE boot the installer environment.
Use The Installer
-
Boot the generated ISO or netboot environment on the target machine.
-
Log in as the
nixosuser. -
The login shell launches:
/etc/auto-install.sh -
The installer queries the target flake:
git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git -
Available installation profiles are discovered from:
nixosConfigurations -
Select the host profile to install.
-
Confirm the installation.
-
The installer applies the selected host's Disko storage layout.
-
NixOS is installed using the selected flake configuration.
-
The system reboots into the installed OS.
Storage Management
Disk partitioning is handled by Disko.
The installer no longer contains hardcoded commands such as:
parted
mkfs.ext4
mkswap
mount
Instead, each NixOS host defines its own storage layout.
Example:
{
disko.devices = {
disk.main = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
root = {
size = "-8G";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
swap = {
size = "100%";
content = {
type = "swap";
};
};
};
};
};
};
}
This allows different hosts to define different layouts:
- Proxmox VMs
- Linode instances
- Physical servers
- ZFS systems
- Future hardware-specific layouts
A host without a Disko configuration will not be automatically partitioned.
Installer Process
The generated /etc/auto-install.sh performs the following steps:
-
Fetch available hosts from the configured NixOS flake.
-
Present available
nixosConfigurationsas a menu. -
Confirm the selected installation target.
-
Check whether the selected host has a Disko configuration.
-
Run:
disko --mode destroy,format,mount --flake <flake>#<host> -
Prepare
/mntusing the Disko-generated mount configuration. -
Install NixOS:
nixos-install \ --flake <flake>#<host> \ --no-root-password -
Remove temporary installation files.
-
Reboot.
Configuration Notes
The installer currently assumes:
-
Target flake:
git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git -
Host definitions are under:
nixosConfigurations -
The installer has network access before installation.
-
SSH is enabled.
-
Root SSH login is permitted.
-
The timezone is:
Australia/Brisbane -
The target host is responsible for defining its own storage layout.
Change these values in installer.nix if your environment differs.
Security Notes
installer.nix currently contains:
- Git credentials
- Password hashes
- SSH public keys
Treat the repository and generated installer images as sensitive.
For production use, consider replacing embedded credentials with:
- Short-lived tokens
- SSH deploy keys
- External secrets management
- Runtime credential injection
Safety Warnings
This installer is destructive.
The command:
disko --mode destroy,format,mount
will erase any disks defined by the selected host's Disko configuration.
Always verify:
- The selected host profile.
- The Disko device paths.
- The target machine.
Never boot this installer on a machine containing important data unless the storage configuration has been reviewed.
Troubleshooting
No hosts appear in the menu
Check that the installer can reach the flake repository:
nix eval --json \
"git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git#nixosConfigurations" \
--apply builtins.attrNames
Selected host has no Disko configuration
The installer checks for:
config.disko.devices
Hosts without Disko storage definitions must either:
- Add a Disko module, or
- Be installed using another storage method.
Disko evaluation fails
Check the selected host locally:
nix eval \
".#nixosConfigurations.<host>.config.disko.devices"
Installation fails fetching the flake
Verify:
- Network connectivity.
- Git credentials.
- Flake input availability.
Installer does not start automatically
Run manually:
sudo /etc/auto-install.sh