This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2026-07-15 08:19:54 +10:00
2026-07-15 08:19:54 +10:00
2026-07-15 08:19:54 +10:00
2026-07-15 07:42:10 +10:00
2026-07-15 08:19:54 +10:00

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-iso image using nixos-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 nixos and root users.
    • Provides the generated /etc/auto-install.sh installation 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

  1. Boot the generated ISO or netboot environment on the target machine.

  2. Log in as the nixos user.

  3. The login shell launches:

    /etc/auto-install.sh
    
  4. The installer queries the target flake:

    git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git
    
  5. Available installation profiles are discovered from:

    nixosConfigurations
    
  6. Select the host profile to install.

  7. Confirm the installation.

  8. The installer applies the selected host's Disko storage layout.

  9. NixOS is installed using the selected flake configuration.

  10. 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:

  1. Fetch available hosts from the configured NixOS flake.

  2. Present available nixosConfigurations as a menu.

  3. Confirm the selected installation target.

  4. Check whether the selected host has a Disko configuration.

  5. Run:

    disko --mode destroy,format,mount --flake <flake>#<host>
    
  6. Prepare /mnt using the Disko-generated mount configuration.

  7. Install NixOS:

    nixos-install \
      --flake <flake>#<host> \
      --no-root-password
    
  8. Remove temporary installation files.

  9. 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
S
Description
No description provided
Readme
184 KiB
Languages
Nix 85.9%
Shell 14.1%