feat(installer): enhance NixOS installer with SSH access and encryption password input

This commit is contained in:
2026-07-02 14:17:49 -04:00
committed by Richie
parent b252b0bf6e
commit ddea13b93a
4 changed files with 125 additions and 15 deletions
+30 -3
View File
@@ -6,7 +6,7 @@ import curses
import logging
import sys
from argparse import ArgumentParser
from os import getenv
from os import environ, getenv
from pathlib import Path
from random import getrandbits
from subprocess import run
@@ -38,6 +38,29 @@ REQUIRED_COMMANDS = (
)
def configure_terminal() -> None:
"""Force a terminal type every live system has a terminfo entry for.
Terminals such as kitty advertise TERM values (xterm-kitty) that live
systems have no terminfo entry for, so setupterm fails before the TUI
can start.
"""
environ["TERM"] = "xterm-256color"
if getenv("TERMINFO") or getenv("TERMINFO_DIRS"):
return
terminfo_fallback_directories = (
Path("/run/current-system/sw/share/terminfo"),
Path("/usr/share/terminfo"),
Path("/etc/terminfo"),
Path("/lib/terminfo"),
)
existing_directories = [str(directory) for directory in terminfo_fallback_directories if directory.is_dir()]
if existing_directories:
environ["TERMINFO_DIRS"] = ":".join(existing_directories)
def partition_disk(disk: str, swap_size: int, reserve: int = 0) -> None:
"""Partition a disk.
@@ -299,8 +322,8 @@ def installer(
check=True,
)
# Fixed mount point for the new system; the installer runs as root on a fresh disk
mnt_dir = "/tmp/nix_install" # noqa: S108
# nixos-install rejects mount points under world-writable paths like /tmp
mnt_dir = "/mnt"
Path(mnt_dir).mkdir(parents=True, exist_ok=True)
@@ -336,10 +359,14 @@ def main(argv: Sequence[str] | None = None) -> None:
logger.info("installer runtime dependencies are available")
return
configure_terminal()
state = curses.wrapper(draw_menu)
encrypt_key = getenv("ENCRYPT_KEY")
if not encrypt_key:
encrypt_key = state.encryption_password
if not state.selected_device_ids:
logger.error("No disks selected; exiting without installing")
sys.exit(1)