Following the 'the install script assumed too much' rule (Scott 2026-06-06):
- Required --disk, --efi, --nixos — no more auto-detect of partitions
- --new-size + --shrink replace implicit 'shrink Windows, mkpart at end'
- --no-shrink for installs into pre-prepared free space
- --no-fetch requires local flake (refuses network fetch)
- --dry-run prints plan and exits (validates pre-flight checks)
- Safety: refuses if --efi isn't GUID c12a7328-..., if partitions don't
belong to --disk, if --nixos is mounted as / or /boot, if --swap
duplicates --nixos
- Local flake preferred: ./flake.nix next to script beats network URL
- Help text via --help extracted from the script header
- Same idempotency for mount/hardware-config/nixos-install; only --shrink
is the one-time non-idempotent step
Tested: bash -n, --help, dry-run with invalid/missing args all pass.
Review of branch t490-dualboot (laptop-config#1) found three correctness
issues in the new install.sh. This commit fixes them:
1. parted mkpart range used '-NIXOS_SIZE 100%' which on a T490 with a
recovery partition at the end of the disk would overlap that
recovery partition and fail. The new code computes the start of the
freed space as the new end of the (now shrunken) Windows partition
and uses explicit MiB offsets, so the new partition lands in the
space ntfsresize actually freed.
2. SWAP_SIZE was advertised in the user-facing plan (lines 100-106 of
the original) but no swap partition was ever created and swapon was
never run. The new code creates a linux-swap partition after the
NixOS root, runs mkswap, and swapon. The total shrink applied to
the Windows partition is now nixos_bytes + swap_bytes.
3. The 'sort | tail -1' trick for finding the new partition breaks
when more than one new partition is created (NixOS root + swap
would both qualify) and is fragile for disks with 10+ existing
partitions. The new code snapshots the partition list before mkpart
and uses comm -13 to diff, then picks the lowest-numbered new
partition for the NixOS root and the next one for swap.
Reported-by: agent-engineering review of sscoble/laptop-config#1
- modules/laptop.nix: add systemd-boot extraEntries for Windows Boot Manager
Chainloads $ESP/EFI/Microsoft/Boot/bootmgfw.efi. sort-key 'z_windows' puts
it after NixOS generations in the menu. Explicit entry works on all
systemd-boot versions; NixOS 26.05 'Yarara' may also autodetect on
shared ESP, in which case the duplicate is harmless.
- install.sh: guided dual-boot installer. Shrinks Win11 NTFS with ntfsresize
(no data loss), creates NixOS ext4 root, mounts shared ESP, runs
nixos-install with this flake. Idempotent except for the partition shrink.
- MIGRATION.md: new T490 + Windows 11 dual-boot section, with manual
fallback and NixOS 26.05 compatibility notes.