Installation

Emanix installs from its own live ISO. There are two ways to get one, and the first needs nothing but the distribution.

  • The distribution image. The distribution ships the standalone installer image itself. It carries no host keys: an interactive install mints the host key on the target. This is how a stranger installs Emanix without owning a personal dotfiles repo. It is an installer, not a rescue or debug image.
  • A declared-host ISO. A consumer that declares its hosts builds its own ISO with emanix.installer.flake and mounts a <host>-keys/ medium beside the repo, so a known host can decrypt its secrets on first boot. This is the fleet path, not the default.

fresh-emanix-install ships with the distribution, is baked into both images, and runs on the booted target. It does the install.

1. Before you start: disable Secure Boot

Disable Secure Boot in the machine's firmware setup (on a ThinkPad: F1 at the logo → Security → Secure Boot → Disabled) and confirm UEFI mode. This is a prerequisite for every install below, not one of its steps.

The bootloader is unsigned. With Secure Boot enabled the system installs cleanly and then will not boot, so the installer warns.

2. 1. Install from the distribution image

  1. Get the image: download it, or build it.

    The distribution publishes the installer image as a release asset, under a name that does not change, so this URL always names the current one:

    curl -LO https://github.com/scott-whitson/emanix/releases/latest/download/emanix-installer.iso
    

    A SHA256SUMS file sits beside it, and the image carries a build provenance attestation that says who built it:

    sha256sum -c SHA256SUMS
    gh attestation verify emanix-installer.iso --repo scott-whitson/emanix
    

    Write it to a stick of at least 2 GiB (the image is about 1.4 GiB):

    sudo dd if=emanix-installer.iso of=/dev/sdX bs=4M conv=fsync status=progress
    

    To build it instead, on a machine you already have and from any directory:

    nix run github:scott-whitson/emanix#iso              # build; print the ISO path
    nix run github:scott-whitson/emanix#iso -- /dev/sdX  # build, then flash it
    

    Inside a checkout, nix build .#installerIso builds the same image. The image carries no keys. Releases are date-tagged rather than versioned: a distribution pinned to a flake has no version number to put on a download.

  2. Boot the target from the stick. Its volume label is emanix.
  3. Bring up the network. Ethernet comes up on its own. For WiFi, the ISO ships NetworkManager with the iwd backend, so nmtui, nmcli and iwctl all work:

    nmtui                                    # nothing to remember
    nmcli device wifi connect <ssid> --ask
    

    iwctl works here and not on the machine you end up with: the installed host does not get the iwd backend, so nmtui and nmcli are the two that carry over, and neither needs the interface name. See Network.

  4. Install, with no host argument:

    sudo fresh-emanix-install
    

    With no host name the installer switches to interactive mode and invents the host as it goes. A name that matches a nixosConfigurations attribute takes the pre-staged path unchanged; anything else, including no name, is a new machine.

  5. Answer the questions the installer asks: hostname, username, encryption, filesystem, swap and graphics. Network is checked, not asked — the installer only involves you if there is no route, in which case it offers to open nmtui. The questions are listed in full below.
  6. Type yes once to wipe the target disk. disko's own second confirmation is suppressed, because you have already answered it.
  7. Set the user's password when prompted — or hand it in through EMANIX_USER_PASSWORD, below — then reboot and remove the stick.
  8. Later, run emanix-init to turn /etc/nixos into a git repository you own. This is optional; the machine runs without it. See Making the config yours below.

2.1. Install without a terminal

The installer reads its answers from standard input and its password from the environment, so an install can run with no terminal anywhere in the loop — from your own machine over ssh, or from cloud-init:

read -rsp 'password for the new user: ' EMANIX_USER_PASSWORD; echo
export EMANIX_USER_PASSWORD
printf '<hostname>\n<username>\nn\n\n\n\nyes\n' | \
  sudo -E fresh-emanix-install

The seven lines are the six questions below in order, then yes for the wipe. Three things make that work rather than hang:

  • The password goes to chpasswd on a pipe, never as an argument — an argument is readable by every user in /proc/<pid>/cmdline. The installer moves EMANIX_USER_PASSWORD out of the environment before the first child process starts, so none of the root children before the password step can read it back from /proc/<pid>/environ either.
  • The interactive password prompt runs passwd, which reads /dev/tty and discards input already queued at every prompt. Answers sent down a pipe therefore cannot reach it. With a password in the environment, passwd is not used at all.
  • Without a terminal and without that variable, the installer says so at once and stops, rather than waiting at a prompt nobody can see.

Encryption is the one question that cannot be answered this way. disko asks for the LUKS passphrase at its own prompt, so an unattended install answers n to the encryption question and the disk is unencrypted. Encrypting without a terminal needs a passphrase file handed to disko, which the installer does not do yet.

The run ends without rebooting: at the end of the answers the reboot prompt reads end-of-input as no, which leaves the target mounted so you can inspect it before deciding.

The rest of this section describes what the installer does. The declared-host path, where the image carries a host key instead, is the next section.

2.2. What it asks

Six questions, in this order:

Question Notes
Hostname Validated as RFC 1123 — lowercase letters, digits, hyphens
Username Your account on the new machine, same character rules
LUKS Whole-disk encryption, on by default
Filesystem btrfs (with subvolumes) or ext4
Swap A size like 8G, or 0 for none
Graphics amd, intel or none; lspci supplies the default

Network is not a question — it checks, and only involves you if there is no route, in which case it offers to open nmtui.

EWM launches from tty1 and loses the DRM-master race unless the driver is in the initrd, so a wrong answer here is a black screen on a machine whose owner has no other console.

2.3. What it generates

A complete flake in /etc/nixos, whose only machine-specific file is host.nix:

{
  hostName   = "testbox";
  device     = "/dev/vda";
  luks       = false;
  filesystem = "btrfs";
  swapSize   = "2G";
  gpu        = null;              # "amd" or "intel" on a graphical host
  hardwareModule = null;          # a nixos-hardware module, if you know yours
}

Everything else in that flake reads from those values. The disk layout comes from emanix.lib.mkDisk, so the disk parameters above are the whole description of the machine's disk; gpu is the only other thing a graphical host must set.

Before anything is erased the installer prints your answers back — hostname, username, encryption, filesystem, swap, graphics — immediately above the wipe confirmation. The preflight proves the machine is ready; that block is how you check the installer understood you.

2.4. The preflight

Check What it means
repo The flake was found. /etc/emanix/flake on the ISO, or $EMANIX_REPO
keys A private host key for <host> was found on the operator-mounted <host>-keys/ medium, and its fingerprint matches the key your secrets are encrypted to. An interactive install mounts no medium — the target's key is generated fresh — and reports it as such
UEFI The machine booted in UEFI mode (/sys/firmware/efi exists)
network cache.nixos.org is reachable
disk A target disk was identified
Secure Boot Reported, not required — see below

Anything missing aborts before the disk is touched. Two options are available:

sudo fresh-emanix-install --check-only     # preflight, then exit
sudo fresh-emanix-install --disk /dev/X    # override disk auto-detection

--check-only needs no root, touches nothing, and prints the checklist above. Run it first.

The fingerprint check belongs to the declared-host path: the private key is on the mounted <host>-keys/ medium, and the check compares it against keys/<host>_host_ed25519.pub — the actual recipient your secrets are encrypted to — and fails closed on a mismatch. The alternative is discovering the wrong key after the disk is gone. An interactive install has no key to compare against, so it skips the check.

Disk auto-detection picks the largest non-removable, writable device with no mounted partitions, which skips the stick you booted from. On a host declared in your flake, the installer also cross-checks that against the device your disk layout declares and refuses to continue if they disagree — a disagreement usually means a VM, or the wrong pick.

2.5. What it then does

The stages are numbered, so a long step is visibly a step and not a hang.

  • Asks you to type yes to wipe the target — once. disko's own second confirmation is suppressed, because you have already answered it and it would block any unattended install
  • Partitions and formats with disko (destroy,format,mount), prompting for a disk-encryption passphrase if the layout declares LUKS — which is the one question an unattended install answers n to. This prints a wall of + ... shell tracing; that is normal output, not errors
  • Installs a host key to /mnt/etc/ssh/ — the one from the mounted medium for a known host, a freshly generated one for a new machine, which has no secrets to decrypt
  • Runs nixos-install
  • Takes the primary user's password — from EMANIX_USER_PASSWORD if it is set, otherwise from a bounded prompt that retries — so a failed attempt cannot leave a passwordless account behind
  • Offers to reboot

Remove the stick on reboot.

2.6. Expect the install to compile Emacs

The nixos-install step is the long one.

Most of what a desktop host needs for its Emacs and compositor comes straight from cache.nixos.org, but some of it does not and is compiled on the machine you are installing: ewm-core (Rust, via Smithay), the Emacs itself on the base the host runs (the pwayl/Skia 31.1 fork under EWM, pgtk 31.1 otherwise — see Components), and the Emacs Lisp packages built against it. The exact counts change whenever the base or the package list does, so none is quoted here.

The Lisp is uncacheable for a structural reason. Every Emacs package is built against the host's own Emacs base, so even entirely ordinary packages — xref, project, eldoc — exist in the public cache only as builds against a different Emacs. Change the Emacs and all of them rebuild.

The output is small, so this costs CPU time rather than bandwidth and it scales with how many cores the machine has. Nothing is wrong while it runs.

A binary cache would remove the step entirely, and that is the intended fix. Until it exists, budget for it.

2.7. After the reboot

You land in Emacs. It is the desktop here, not an application inside one.

Key Does
s-<return> A terminal
s-d Launch an application
s-1 … s-9 Switch frame slots
C-c ? Reopen the welcome buffer

A welcome buffer opens on the first start with those keys and a pointer back here. Dismiss it with q for now, or n to never see it again.

Do not run emanix-firstboot on a machine installed this way. That command is the consuming flake's seam — it runs whatever your flake put in emanix.firstboot.text, and a generated host has set nothing, so it prints a message about configuring it and exits. It is for a fleet, not for a machine the installer just invented.

2.8. Making the config yours

The installer leaves a working flake in /etc/nixos. That is enough to run and not enough to live in: root-owned, no git, nowhere to put a secret.

emanix-init

This copies it to ~/flake, initialises git, adds a keys/ directory and a .gitignore at the repository root that commits the public halves and never the private ones, records this machine's own public host key as a future secrets recipient, and runs nix flake check to prove the result still evaluates. It refuses rather than overwrites, and leaves /etc/nixos untouched, so a failed adoption costs nothing.

The welcome buffer offers this as [i] when it finds no config repo.

Rebuild from there afterwards:

sudo nixos-rebuild switch --flake ~/flake

3. 2. Install a declared host

A consumer that declares its hosts builds its own ISO with emanix.installer.flake, which stages the flake at /etc/emanix/flake. The target's host key is not built into the image: you mount a <host>-keys/ medium beside the repo, and resolve_keys reads it from there. This is the fleet path, not the default. Use it when the host is already declared in your flake and its secrets are already encrypted to its own key.

Host-specific install runbooks live in the consuming flake, because they are about that user's machines, disks and keys — not about the distribution.

3.1. Build the ISO

On an existing machine, from your flake repo:

bin/emanix-iso                 # build with your flake staged; prints the ISO path
bin/emanix-iso /dev/sdX        # build and write to a device (destructive)

The ISO stages your whole flake at /etc/emanix/flake. It carries no keys, so the private halves never reach the Nix store.

3.2. Mount the host key

The host's private key is what lets the installed machine decrypt its own secrets on first boot, and it must not be built into the image. Mount a <host>-keys/ medium beside the repo instead; resolve_keys reads the key from there during the install.

A <host>-keys/ medium IS your identity. It carries the private host key that decrypts your secrets. Keep it exactly as carefully as you keep the key itself.

A medium that holds only the .pub half cannot install: the machine would boot without the key its secrets are encrypted to, and the first activation would fail.

3.3. Before you go

The repo comes from your flake and the key from the mounted medium, so there is no USB staging to get right. What still has to be true:

  • Real values are in the encrypted secrets. Placeholders install a system that activates and then fails to do anything useful with them. See Secrets.
  • The host's public key is committed at keys/<host>_host_ed25519.pub, and the private half is present on the <host>-keys/ medium.
  • Secrets are rekeyed for this host, so the encrypted-to-this-machine copies exist.

The public key is the part people skip: secrets are decrypted by the host's own key, so a machine that boots without its key cannot decrypt anything and the first activation fails.

3.4. Install, from the ISO

  1. Boot the stick. Its volume label is emanix.
  2. Bring up the network: ethernet on its own, nmtui for WiFi. The commands are in the first section.
  3. Mount the <host>-keys/ medium beside the repo.
  4. Install, naming the host:

    sudo fresh-emanix-install <host>
    

The host name selects a host you declared in the flake. The installer runs the same stages as an interactive install — the wipe, the partitioning, the nixos-install step, the password prompt, the reboot — with one difference: it installs the host key resolve_keys found on the mounted medium instead of generating a new one, and the preflight checks that key against your secrets recipient.

The path forks at the reboot. Everything from here — first boot, ongoing rebuilds and the manual fallback — continues the declared-host path. A machine installed from the distribution image (step 1) does not run emanix-firstboot and rebuilds from ~/flake, not the consumer's ~/dotfiles; the SSH and WSL sections apply to either install.

4. 3. Installing over SSH

The ISO runs sshd. The nixos user has an empty password, so nothing can log in until you set one:

  • add live.nixos.passwd=<pw> to the kernel command line at boot, or
  • run sudo passwd nixos at the target's console

then ssh nixos@<ip> and drive the install from your own machine. The ISO's host keys are generated fresh at every boot — it runs on tmpfs, so they are ephemeral by construction.

5. 4. First boot

  1. Disk passphrase, if the layout has LUKS
  2. The compositor starts (autologin is opt-in per host; without it you get a login prompt and EWM starts on your first tty1 login)
  3. Run the one-time setup:

    emanix-firstboot
    

This runs whatever your flake put in emanix.firstboot.text. Emanix supplies the command and shellchecks the body at build time — so a broken first-boot script fails your build rather than failing at the one moment nobody is watching a screen they can debug from. It does not supply the steps, because joining a network and pairing file sync are decisions about your infrastructure, not the distribution's.

A typical script joins a mesh VPN, prints the file-sync device id to pair with a hub, and confirms secrets decrypted. If you set nothing, emanix-firstboot prints a message saying so and exits.

If yours pairs file sync, remember that pairing is two-sided: the hub must also accept the new device and share the folders. Printing the id is half the handshake, not all of it.

6. 5. Ongoing

cd ~/dotfiles && sudo nixos-rebuild switch --flake .#<host>

That is the declared-host path: ~/dotfiles is the consumer's checkout. A machine installed from the distribution image rebuilds from the repo emanix-init made, ~/flake.

See Build and Deploy.

7. 6. Manual fallback

If the installer fails partway, everything it automates is an ordinary command. disko reads the layout from the flake — there is no separate config file to write:

# Partition, format and mount, from the declarative layout
sudo disko --mode destroy,format,mount --flake /etc/emanix/flake#<host>

# Install the host key from the mounted <host>-keys/ medium, so agenix can
# decrypt on first boot
sudo install -d -m 755 /mnt/etc/ssh
sudo install -m 600 <host>-keys/<host>_host_ed25519     /mnt/etc/ssh/ssh_host_ed25519_key
sudo install -m 644 <host>-keys/<host>_host_ed25519.pub /mnt/etc/ssh/ssh_host_ed25519_key.pub

# Install, then set the user's password
sudo nixos-install --flake /etc/emanix/flake#<host> --no-root-password
sudo nixos-enter --root /mnt -c 'passwd <username>'

sudo reboot

8. 7. WSL hosts

A wsl host is not installed this way at all — there is no disk layout, no bootloader and no host hardware. The WSL module supplies boot and mounts (it comes from your own flake's nixos-wsl input, not from Emanix); you import a distribution image and apply the flake.

The system must not set its own hostname at activation: that breaks the WSL user-session bootstrap. The host composer sets the hostname as a default so a WSL host can force it empty.