pc: generic hardware profile (no per-machine gen); trim README

This commit is contained in:
mads 2026-07-01 18:09:31 +00:00
parent 2c3b029c83
commit d7b1b8776c
2 changed files with 57 additions and 140 deletions

175
README.md
View file

@ -1,161 +1,64 @@
# mads — NixOS config (one flake, two machines) # nixos
Declarative NixOS for: One flake, two machines. Hyprland + greetd autologin, Zen+Tridactyl, neovim, zsh+starship.
| host | `nixosConfigurations.<name>` | arch | notes | | host | arch | build |
|------|------------------------------|------|-------| |------|------|-------|
| MacBook (M1 Pro, Asahi) | `mbp` | `aarch64-linux` | Apple Silicon support module + vendored firmware | | `mbp` | aarch64 | MacBook M1 Pro (Asahi) |
| Arbitrary x86 PC | `pc` | `x86_64-linux` | plain NixOS | | `pc` | x86_64 | any UEFI x86 |
Everything shared (Hyprland, greetd autologin, Zen+Tridactyl, neovim, zsh+starship,
packages, user) lives in the `common` / `home` modules in `flake.nix`. Host-specific
bits (Asahi firmware/cache vs. x86 boot) are the small inline modules per host.
``` ```
flake.nix inputs + common/home modules + both hosts flake.nix all config (common + home modules, both hosts)
hosts/mbp/hardware-configuration.nix ← DUMMY, regenerate on the Mac config/ raw configs: hypr eww fuzzel nvim
hosts/pc/hardware-configuration.nix ← DUMMY, regenerate on the PC hosts/*/hardware-configuration.nix mbp: regenerate on Mac · pc: generic, as-is
config/ hypr eww fuzzel nvim raw configs (sourced by home-manager) firmware/ Mac Wi-Fi/BT blobs — git-add at install. KEEP REPO PRIVATE.
firmware/ Wi-Fi/BT blobs (Mac only, git-add at install)
``` ```
> **Keep this repo private** — the Mac firmware under `firmware/` is non-redistributable. Set `time.timeZone` in `common`. Rename a host = change the `nixosConfigurations.<name>` key + its `networking.hostName`.
The `hardware-configuration.nix` files are placeholders so the flake evaluates ## Apply
off-target; each is overwritten by `nixos-generate-config` during that machine's install.
---
## Rename a host / set your timezone
- Host name: change the `nixosConfigurations.<name>` key **and** its
`networking.hostName` in `flake.nix` (e.g. `pc``desktop`).
- `time.timeZone` is in the `common` module.
---
## Install on the MacBook (Asahi + NixOS)
Follows the official guide — **always check the latest**, as steps change:
<https://github.com/nix-community/nixos-apple-silicon/blob/main/docs/uefi-standalone.md>
(this config tracks Asahi `main`; currently kernel `linux-asahi 7.0.13`).
> ⚠ **Back up first.** Damaging the GPT / first / last partition can brick the Mac
> and lose all data.
### 1. macOS → install the UEFI environment
In macOS Terminal (admin account):
```sh ```sh
curl https://alx.sh | sh sudo nixos-rebuild switch --flake ~/nixos#mbp # or #pc
nix flake update && sudo nixos-rebuild switch --flake ~/nixos#mbp # update
``` ```
- `r` — resize macOS, leave ≥ 20 GB free for NixOS Roll back = pick an older generation at boot.
- `f` — install into free space → **UEFI environment only**, name it `NixOS`
- Reboot into recovery when told; set **permissive security** for the new OS.
- It reboots into U-Boot (Asahi + U-Boot logos). Power off.
### 2. Build + write the installer USB ## Install: MacBook (Asahi)
On any Linux box with Nix (or download a release ISO from the repo's Releases):
```sh
nix build github:nix-community/nixos-apple-silicon#installer-bootstrap -o installer
sudo dd if=installer/iso/nixos-*.iso of=/dev/sdX bs=4M conv=fsync status=progress
```
(`dd` only — not unetbootin.)
### 3. Boot the installer, partition, mount Full/latest guide: <https://github.com/nix-community/nixos-apple-silicon/blob/main/docs/uefi-standalone.md>. **Back up — a bad partition can brick the Mac.**
Boot the USB (U-Boot → GRUB → installer), then:
1. macOS Terminal: `curl https://alx.sh | sh``r` resize (≥20 GB free) → `f` install **UEFI environment only**, name `NixOS` → recovery: permissive security. Reboots to U-Boot; power off.
2. Installer USB (on a Linux+Nix box): `nix build github:nix-community/nixos-apple-silicon#installer-bootstrap -o installer` then `dd` the ISO to USB.
3. Boot USB → `sudo su`:
```sh ```sh
sudo su sgdisk /dev/nvme0n1 -n 0:0 -s && sgdisk /dev/nvme0n1 -p # note new 8300 part, e.g. p5
sgdisk /dev/nvme0n1 -n 0:0 -s # root fills free space
sgdisk /dev/nvme0n1 -p # find the new 8300 partition number (e.g. p5)
mkfs.ext4 -L nixos /dev/nvme0n1p5 mkfs.ext4 -L nixos /dev/nvme0n1p5
mount /dev/disk/by-label/nixos /mnt && mkdir -p /mnt/boot
mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-partuuid/$(cat /proc/device-tree/chosen/asahi,efi-system-partition) /mnt/boot mount /dev/disk/by-partuuid/$(cat /proc/device-tree/chosen/asahi,efi-system-partition) /mnt/boot
```
### 4. Hardware config + vendored firmware + this flake
```sh
nixos-generate-config --root /mnt nixos-generate-config --root /mnt
git clone <private-remote> /mnt/root/nixos && cd /mnt/root/nixos
# get this repo onto the target (private remote or USB), e.g.: cp /mnt/etc/nixos/hardware-configuration.nix hosts/mbp/
git clone <your-private-remote> /mnt/etc/nixos/config && cd /mnt/etc/nixos/config mkdir -p firmware && cp /mnt/boot/asahi/{all_firmware.tar.gz,kernelcache*} firmware/
cp /mnt/etc/nixos/hardware-configuration.nix hosts/mbp/hardware-configuration.nix
# vendor the Wi-Fi/BT firmware (pure flakes can't read /boot/asahi)
mkdir -p firmware
cp /mnt/boot/asahi/all_firmware.tar.gz firmware/
cp /mnt/boot/asahi/kernelcache* firmware/
git add -f hosts/mbp/hardware-configuration.nix firmware/* git add -f hosts/mbp/hardware-configuration.nix firmware/*
nixos-install --flake .#mbp && reboot
``` ```
### 5. Install ## Install: x86
No hardware generation — `hosts/pc/hardware-configuration.nix` is generic (mounts by label). Boot the NixOS ISO, `sudo -i`:
```sh ```sh
nixos-install --flake .#mbp # sets root password at the end parted /dev/nvme0n1 -- mklabel gpt \
reboot mkpart ESP fat32 1MiB 512MiB set 1 esp on \
``` mkpart primary 512MiB 100%
Boot picker: hold the power button. greetd autologins `mads` into Hyprland.
**First thing after login: `passwd`** (the config ships `initialPassword = "changeme"`).
---
## Install on an x86 PC
Standard NixOS install (<https://nixos.org/manual/nixos/stable/#sec-installation>),
just point `nixos-install` at `.#pc`.
### 1. Boot the NixOS ISO, get network, partition (UEFI/GPT)
```sh
sudo -i
parted /dev/nvme0n1 -- mklabel gpt
parted /dev/nvme0n1 -- mkpart ESP fat32 1MiB 512MiB
parted /dev/nvme0n1 -- set 1 esp on
parted /dev/nvme0n1 -- mkpart primary 512MiB 100%
mkfs.fat -F32 -n BOOT /dev/nvme0n1p1 mkfs.fat -F32 -n BOOT /dev/nvme0n1p1
mkfs.ext4 -L nixos /dev/nvme0n1p2 mkfs.ext4 -L nixos /dev/nvme0n1p2
mount /dev/disk/by-label/nixos /mnt && mkdir -p /mnt/boot && mount /dev/disk/by-label/BOOT /mnt/boot
mount /dev/disk/by-label/nixos /mnt git clone <private-remote> /mnt/root/nixos && cd /mnt/root/nixos
mkdir -p /mnt/boot nixos-install --flake .#pc && reboot
mount /dev/disk/by-label/BOOT /mnt/boot
``` ```
(The `BOOT` / `nixos` labels match the dummy `hosts/pc/hardware-configuration.nix`, Exotic storage controller won't boot? Add its module to `availableKernelModules` in `hosts/pc/hardware-configuration.nix` (`nixos-generate-config --show-hardware-config` lists it).
but the generated one below replaces it with real UUIDs anyway.)
### 2. Hardware config + this flake + install ## After first boot
```sh
nixos-generate-config --root /mnt
git clone <your-private-remote> /mnt/etc/nixos/config && cd /mnt/etc/nixos/config
cp /mnt/etc/nixos/hardware-configuration.nix hosts/pc/hardware-configuration.nix
nixos-install --flake .#pc `passwd` (ships `initialPassword = "changeme"`). If you land on a tty instead of Hyprland, change greetd's `uwsm start hyprland``Hyprland` in `common`.
reboot
```
Then `passwd`.
---
## Day-to-day
```sh
# apply config changes
sudo nixos-rebuild switch --flake ~/nixos#mbp # or #pc
# update everything (nixpkgs + asahi + zen + addons), then rebuild
nix flake update
sudo nixos-rebuild switch --flake ~/nixos#mbp
# roll back: pick a previous generation in the boot menu
```
Both `apple-silicon` and `nixpkgs` are cached (asahi via its Cachix), so updates
download rather than compile.
---
## Verify-on-first-boot (can't be checked off-machine)
- **greetd session** — the command is `uwsm start hyprland`. If you land on a blank
tty instead of Hyprland, change it to `command = "Hyprland"` in `common`.
- **Asahi `hardware.asahi.*`** — firmware path / sound options, per the guide above.

View file

@ -1,8 +1,20 @@
# DUMMY x86 hardware config — just enough for `nix eval`/build off-target. # Generic x86_64 UEFI hardware profile — boots on most machines WITHOUT
# OVERWRITTEN at install by: nixos-generate-config --root /mnt # per-machine `nixos-generate-config`, as long as you format the disks with the
# then copy /mnt/etc/nixos/hardware-configuration.nix here. # labels `nixos` (root) and `BOOT` (ESP).
{ ... }: #
# `availableKernelModules` covers NVMe + SATA/AHCI + USB boot. An exotic storage
# controller could need one more entry — check with:
# nixos-generate-config --show-hardware-config
{ modulesPath, ... }:
{ {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [
"nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sr_mod" "vmd"
];
hardware.enableRedistributableFirmware = true; # wifi/gpu firmware for arbitrary hw
fileSystems."/" = { fileSystems."/" = {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; fsType = "ext4";
@ -11,4 +23,6 @@
device = "/dev/disk/by-label/BOOT"; device = "/dev/disk/by-label/BOOT";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ ];
} }