3.2 KiB
Nix Auto Installer
This repository builds a custom NixOS installer ISO that can install one of the hosts exposed by a separate NixOS flake.
The ISO is intentionally opinionated for a local environment. When the nixos
user logs in, it runs /etc/auto-install.sh, asks which flake host to install,
partitions /dev/sda, installs NixOS, and reboots.
Repository Layout
flake.nixdefines the build output. The default package is aninstall-isoimage produced withnixos-generators.installer.nixdefines the installer ISO configuration, including SSH, Git credentials, users, and the generated auto-install script.
Requirements
- A machine with Nix installed and flakes enabled.
- Network access to the configured NixOS flake repository.
- A target machine or VM where
/dev/sdais the disk you want to erase.
Build The ISO
From the repository root:
nix build
The generated ISO will be available through the result symlink.
Use The Installer
-
Boot the generated ISO on the target machine.
-
Log in as the
nixosuser, or connect over SSH if networking is available. -
The login shell runs
/etc/auto-install.sh. -
Choose one of the hosts returned by:
nix eval --json --no-use-registries --no-accept-flake-config \ "git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git#nixosConfigurations" \ --apply builtins.attrNames -
Confirm the install when prompted.
What The Installer Does
The generated /etc/auto-install.sh script:
- Reads available host names from the configured flake.
- Prompts for the host profile to install.
- Asks for confirmation.
- Repartitions
/dev/sdawith an MBR layout:/dev/sda1: ext4 root filesystem labelednixos/dev/sda2: swap partition labeledswap
- Mounts the new root filesystem at
/mnt. - Runs
nixos-install --flake. - Reboots the machine.
Configuration Notes
The installer currently assumes:
- The flake to install is
git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git. - Install targets are exposed under
#nixosConfigurations. - The install disk is always
/dev/sda. - The timezone is
Australia/Brisbane. - SSH is enabled and root login is permitted.
- The generated ISO has both
rootandnixosusers configured with hashed passwords.
Change these values in installer.nix before building if your environment
differs.
Safety Warnings
This installer is destructive. Once confirmed, it repartitions /dev/sda
without another prompt. Make sure the target disk name is correct before using
the ISO on real hardware.
installer.nix currently contains embedded Git credentials, password hashes,
and an SSH public key. Treat this repository and any generated ISO as sensitive.
Prefer moving credentials to a safer delivery mechanism before sharing the repo
or ISO.
Troubleshooting
-
If no host choices appear, confirm the target machine has network access and can reach the configured flake URL.
-
If installation fails while fetching the flake, verify the embedded Git credentials are valid.
-
If the wrong disk is being partitioned, stop immediately and update the disk paths in
installer.nix. -
If the login shell does not start the installer, run it manually:
sudo /etc/auto-install.sh