feat: pi-sdcard template (Raspberry Pi NixOS SD-card image, native or cross-built) #6

Open
jingus wants to merge 2 commits from t3code/211fb33b into main
Owner

A Raspberry Pi 3/4/5 (aarch64) NixOS starter that builds a flashable SD-card image, in the spirit of basalt-rs/nix-pi-base but as a starters template: MBR layout, FAT32 firmware partition (Pi firmware + U-Boot, extlinux boot), auto-expanding ext4 root, headless key-only-ssh defaults (wheel user pi, initialPassword for the HDMI console only).

Build routes (nix build .#sd-image picks per host)

Host Route
aarch64-linux (or x86_64 + binfmt) nixosConfigurations.pi — closure substitutes from cache.nixos.org
x86_64-linux, no emulation nixosConfigurations.pi-cross — cross-compiled (nixpkgs.buildPlatform = x86_64-linux), runs anywhere

Plus a safety-checked flasher: nix run .#flash -- /dev/sdX (refuses non-/dev targets, non-block devices, and mounted devices; decompresses the .img.zst on the fly).

Verification (all local, per the too-heavy-for-CI rule)

  • Full cross build completed on this x86_64 host: 1.5 GiB .img.zst (3.85 GiB image), 509 derivations built locally, rest substituted
  • Artifact inspected: valid MBR (30 MiB FAT + bootable ext4), FAT carries u-boot + Pi 3/4/5 DTBs + firmware + config.txt, ext4 passes e2fsck -fn, extlinux entries point at the cross-built 6.18.56 kernel, ~2050 store paths + nix-path-registration present
  • nix flake init -t path:...#pi-sdcard on a fresh copy → nix flake check + nix run .#validate green (evaluation-only gates)
  • flash app guard paths exercised (usage / non-block / non-/dev / mounted device)
  • root nix fmt + nix flake check green

CI

The image is a multi-hour build, so it is deliberately not built in CI: the template's own workflow runs the two canonical gates (eval-only), and the root workflow gets a heavy skip list so it does not instantiate this template per-push. The README standards section now codifies that heavy templates are eval-gated and must be built locally before merging.

Note: x86_64-darwin is not in the template's systems — nixpkgs unstable dropped it in 26.11 (documented in the template README + parts.nix).

A Raspberry Pi 3/4/5 (aarch64) NixOS starter that builds a **flashable SD-card image**, in the spirit of basalt-rs/nix-pi-base but as a starters template: MBR layout, FAT32 firmware partition (Pi firmware + U-Boot, extlinux boot), auto-expanding ext4 root, headless key-only-ssh defaults (wheel user `pi`, `initialPassword` for the HDMI console only). ## Build routes (`nix build .#sd-image` picks per host) | Host | Route | | --- | --- | | aarch64-linux (or x86_64 + binfmt) | `nixosConfigurations.pi` — closure substitutes from cache.nixos.org | | x86_64-linux, no emulation | `nixosConfigurations.pi-cross` — cross-compiled (`nixpkgs.buildPlatform = x86_64-linux`), runs anywhere | Plus a safety-checked flasher: `nix run .#flash -- /dev/sdX` (refuses non-/dev targets, non-block devices, and mounted devices; decompresses the `.img.zst` on the fly). ## Verification (all local, per the too-heavy-for-CI rule) - Full **cross build completed** on this x86_64 host: 1.5 GiB `.img.zst` (3.85 GiB image), 509 derivations built locally, rest substituted - Artifact inspected: valid MBR (30 MiB FAT + bootable ext4), FAT carries u-boot + Pi 3/4/5 DTBs + firmware + config.txt, ext4 passes `e2fsck -fn`, extlinux entries point at the cross-built 6.18.56 kernel, ~2050 store paths + nix-path-registration present - `nix flake init -t path:...#pi-sdcard` on a fresh copy → `nix flake check` + `nix run .#validate` green (evaluation-only gates) - flash app guard paths exercised (usage / non-block / non-/dev / mounted device) - root `nix fmt` + `nix flake check` green ## CI The image is a multi-hour build, so it is deliberately not built in CI: the template's own workflow runs the two canonical gates (eval-only), and the **root workflow gets a `heavy` skip list** so it does not instantiate this template per-push. The README standards section now codifies that heavy templates are eval-gated and must be built locally before merging. Note: x86_64-darwin is not in the template's `systems` — nixpkgs unstable dropped it in 26.11 (documented in the template README + parts.nix).
feat: pi-sdcard template (Raspberry Pi NixOS SD-card image, native or cross-built)
Some checks failed
ci / flake-check (push) Successful in 19s
ci / flake-check (pull_request) Successful in 21s
ci / templates (push) Failing after 1m20s
ci / templates (pull_request) Failing after 1m1s
13cb4c5a58
A Raspberry Pi 3/4/5 (aarch64) NixOS starter that builds a flashable
SD-card image: MBR layout, FAT32 firmware partition (Pi firmware +
U-Boot, extlinux), auto-expanding ext4 root, headless key-only-ssh
defaults. One configuration evaluated two ways: pi (native aarch64 or
x86_64+binfmt, substitutes from cache.nixos.org) and pi-cross
(cross-compiled from x86_64, no emulation needed; verified with a full
local build). nix build .#sd-image picks the route per host; a
safety-checked nix run .#flash -- /dev/sdX writes the card.

The image is a multi-hour build, so its CI and the root CI gate on
evaluation only: pi-sdcard joins the root workflow's heavy skip list
(and the standards say such templates are built locally before
merging).
Merge remote-tracking branch 'origin/main' into t3code/211fb33b
Some checks failed
ci / flake-check (push) Successful in 16s
ci / flake-check (pull_request) Successful in 28s
ci / templates (push) Failing after 1m13s
ci / templates (pull_request) Failing after 1m0s
2210f6be64
# Conflicts:
#	README.md
#	nix-modules/templates.nix
Some checks failed
ci / flake-check (push) Successful in 16s
ci / flake-check (pull_request) Successful in 28s
ci / templates (push) Failing after 1m13s
ci / templates (pull_request) Failing after 1m0s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 't3code/211fb33b:t3code/211fb33b'
git switch 't3code/211fb33b'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 't3code/211fb33b'
git switch 't3code/211fb33b'
git rebase 'main'
git switch 'main'
git merge --ff-only 't3code/211fb33b'
git switch 't3code/211fb33b'
git rebase 'main'
git switch 'main'
git merge --no-ff 't3code/211fb33b'
git switch 'main'
git merge --squash 't3code/211fb33b'
git switch 'main'
git merge --ff-only 't3code/211fb33b'
git switch 'main'
git merge 't3code/211fb33b'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jingus/starters!6
No description provided.