Add HM bootstrap script and tidy installer workflow

This commit is contained in:
randogoth 2026-02-02 14:04:56 +02:00
parent dd15c09fdd
commit d1713bdc99
10 changed files with 184 additions and 43 deletions

View file

@ -2,10 +2,10 @@
set -euo pipefail
# Non-interactive Btrfs installer using the flake in this repo.
# Defaults: DISK=/dev/vda HOSTNAME=nanuqsaurus
# Defaults: DISK=/dev/vda TARGET_HOST=nanuqsaurus
DISK=${DISK:-/dev/vda}
HOSTNAME=${HOSTNAME:-nanuqsaurus}
TARGET_HOST=${TARGET_HOST:-nanuqsaurus}
SCRIPT_DIR=$(cd -- "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_ROOT=$(cd -- "${SCRIPT_DIR}/.." && pwd)
@ -44,9 +44,9 @@ fi
echo "[6/7] Generating hardware config"
mkdir -p /mnt/etc/nixos/hosts
nixos-generate-config --root /mnt --show-hardware-config > "/mnt/etc/nixos/hosts/local-${HOSTNAME}-hardware.nix"
nixos-generate-config --root /mnt --show-hardware-config > "/mnt/etc/nixos/hosts/local-${TARGET_HOST}-hardware.nix"
host_file="/mnt/etc/nixos/hosts/local-${HOSTNAME}.nix"
host_file="/mnt/etc/nixos/hosts/local-${TARGET_HOST}.nix"
if [ ! -e "${host_file}" ]; then
cat > "${host_file}" <<EOF
{ inputs, ... }:
@ -55,18 +55,20 @@ if [ ! -e "${host_file}" ]; then
imports = [
inputs.lix-module.nixosModules.lixFromNixpkgs
../modules/system/base.nix
../modules/system/packages.nix
../modules/system/home-manager-skel.nix
../modules/desktop/gnome-minimal.nix
../modules/users/admin.nix
./local-${HOSTNAME}-hardware.nix
./local-${TARGET_HOST}-hardware.nix
];
networking.hostName = "${HOSTNAME}";
networking.hostName = "${TARGET_HOST}";
}
EOF
fi
echo "[7/7] Installing ${HOSTNAME} via flake"
nixos-install --root /mnt --flake "/mnt/etc/nixos#${HOSTNAME}" --no-root-passwd |& tee /tmp/nixos-install.log
echo "[7/7] Installing ${TARGET_HOST} via flake (local-${TARGET_HOST})"
nixos-install --root /mnt --flake "/mnt/etc/nixos#local-${TARGET_HOST}" --no-root-passwd |& tee /tmp/nixos-install.log
echo "Install log saved to /tmp/nixos-install.log"
echo "Install complete. You can reboot now."