The disk phase was the dominant source of incomplete installs. Six
concrete failure modes addressed in one pass:
1. Live-ISO USB excluded from the disk picker. select_disk previously
filtered loop|ram|zram|sr but not the device the installer booted
from; picking it would format the boot media mid-install. New
detect_live_iso_devices walks /, /iso, /run/initramfs/live,
/nix/.ro-store, /nix/store and resolves each backing device to its
parent disk via lsblk -no PKNAME. Override with
NOMARCHY_INSTALL_ALLOW_ISO_TARGET=1 for the developer case.
2. 10 GiB minimum-capacity preflight. Disko fails late and obscurely
on undersized media; surface it while the picker is still open.
3. prewipe_target_drive rewritten:
- Enumerates every active dm-crypt mapping via dmsetup ls and
closes those whose backing device is on the target drive. The
old version only knew about the hardcoded names "crypted" /
"crypted_main" so an aborted multi-disk run or a non-Nomarchy
install would leave a holder open and silently break the wipe.
- Drops `|| true` from wipefs / sgdisk / dd. After the LUKS and
swap teardown above, a real failure means something is still
holding the device — surface that instead of papering over it.
- udevadm settle bounded to 30s so a flapping USB can't hang.
- Post-wipe sanity check: refuse to hand the disk to disko if
anything is still mounted off it.
4. run_disko_with_retry wraps the disko call. On failure, shows the
last 30 lines of output via gum style and offers Retry /
View full log / Abort. set -e is suspended for the disko call so
the exit code can be inspected. The previous bare `disko --mode
disko` aborted the whole installer with output scrolled past.
5. Sed-templated disko-golden.nix + disko-btrfs-multi.nix pair
replaced by a single disko-config.nix Nix function of
{ mainDrive, extraDrives ? [] } called via --argstr / --arg.
Templating Nix via shell-escaped string substitution caused at
least one production bug (3aadc36 fixed embedded-newline
escaping); function arguments are the right shape and eliminate
the entire class of escaping concerns. Single-disk path is
`extraDrives = []`; multi-disk gets BTRFS `-d single -m raid1`
plus the additional /dev/mapper/* devices. Hosts that shipped
/etc/disko-golden.nix now ship /etc/disko-config.nix.
6. EXIT trap added so the tmpfs LUKS key file (/dev/shm/nomarchy-
luks.key) is removed even if the script aborts between key-write
and the explicit unset. Replaced redundant `shred -u` on tmpfs
with `rm -f` (already in RAM).
Verification: bash -n on install.sh, nix-instantiate parse + strict
eval on disko-config.nix in both single and multi shapes, full
nix flake check --no-build evaluating all three NixOS configurations
(default, nomarchy-installer, nomarchy-live) plus the installerVm.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
123 lines
3.7 KiB
Nix
123 lines
3.7 KiB
Nix
{ config, pkgs, inputs, lib, ... }:
|
|
|
|
# Minimal TTY Installer ISO Configuration
|
|
#
|
|
# This creates a minimal, text-only installation environment.
|
|
# No desktop environment - just TTY with gum-based installer.
|
|
|
|
{
|
|
imports = [
|
|
../core/system/nix.nix
|
|
../core/system/branding.nix
|
|
];
|
|
|
|
# Base installation media configuration is handled by the module imported in flake.nix
|
|
|
|
# Console configuration for a pleasant TTY experience.
|
|
# keyMap and i18n.defaultLocale are mkDefault — the install.sh keymap step
|
|
# calls `loadkeys` at runtime to honor the user's pick during the install,
|
|
# and writes the chosen value into the *installed* system's system.nix.
|
|
console = {
|
|
font = "ter-v16n";
|
|
packages = [ pkgs.terminus_font ];
|
|
keyMap = lib.mkDefault "us";
|
|
};
|
|
|
|
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
|
|
|
|
# ISO Branding
|
|
isoImage.volumeID = lib.mkForce "NOMARCHY_INSTALLER";
|
|
isoImage.edition = lib.mkForce "minimal";
|
|
|
|
# Essential packages for installation
|
|
environment.systemPackages = with pkgs; [
|
|
# Core utilities
|
|
git
|
|
vim
|
|
curl
|
|
wget
|
|
|
|
# TUI installer dependencies
|
|
gum
|
|
|
|
# Disk tools
|
|
inputs.disko.packages.${pkgs.stdenv.hostPlatform.system}.disko
|
|
parted
|
|
btrfs-progs
|
|
cryptsetup
|
|
|
|
# Network tools
|
|
networkmanager
|
|
|
|
# System info
|
|
lshw
|
|
pciutils
|
|
usbutils
|
|
|
|
# Installer command
|
|
(pkgs.writeShellScriptBin "nomarchy-install" ''
|
|
exec /etc/install.sh "$@"
|
|
'')
|
|
];
|
|
|
|
# Enable NetworkManager for easy network setup
|
|
networking.networkmanager.enable = true;
|
|
|
|
# Auto-login to TTY as root for installation
|
|
services.getty.autologinUser = lib.mkForce "root";
|
|
|
|
# Display welcome message and installer info
|
|
environment.etc."motd".text = ''
|
|
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ ║
|
|
║ NOMARCHY INSTALLER ║
|
|
║ ║
|
|
║ Run 'nomarchy-install' to start the installation wizard ║
|
|
║ ║
|
|
║ For network setup: nmtui ║
|
|
║ For manual install: see /etc/nomarchy/ ║
|
|
║ ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
|
|
'';
|
|
|
|
# Make the installer script available
|
|
environment.etc."install.sh" = {
|
|
source = ../installer/install.sh;
|
|
mode = "0755";
|
|
};
|
|
|
|
environment.etc."hardware-db.sh" = {
|
|
source = ../installer/hardware-db.sh;
|
|
mode = "0644";
|
|
};
|
|
|
|
# Symlink for easy access (merged into systemPackages above)
|
|
# The nomarchy-install script is created by writeShellScriptBin in the main list
|
|
|
|
# Include disko configuration
|
|
environment.etc."disko-config.nix".source = ../installer/disko-config.nix;
|
|
|
|
# Include Nomarchy source for installation
|
|
environment.etc."nomarchy".source = inputs.self;
|
|
|
|
# Disable graphical stuff - this is TTY only
|
|
services.xserver.enable = false;
|
|
services.displayManager.sddm.enable = lib.mkForce false;
|
|
|
|
# Ensure we have a proper shell environment
|
|
programs.bash.completion.enable = true;
|
|
|
|
# Auto-launch installer on the main TTY (tty1)
|
|
programs.bash.loginShellInit = ''
|
|
if [ "$(tty)" = "/dev/tty1" ]; then
|
|
nomarchy-install
|
|
fi
|
|
'';
|
|
|
|
# Include documentation
|
|
documentation.enable = true;
|
|
documentation.man.enable = true;
|
|
}
|