From 029bb09745e14ff48b25be7142f1f052f8fecd97 Mon Sep 17 00:00:00 2001 From: Padreug Date: Sun, 20 Sep 2026 11:26:02 +0200 Subject: [PATCH] refactor(deploy): key the Pi build machinery by board MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit piBaseModules hardcoded the nixos-hardware raspberry-pi-5 module and our raspberry-pi-5.nix glue, so mkPiInstalled/mkPiImage could only ever produce a Pi 5. Everything else in the Pi runtime is board-agnostic. Introduce `piBoards`, keyed by machine model — the parameter already threaded through both builders — pairing each board's nixos-hardware module with its glue file, and have piBaseModules look the pair up. Same modules in the same order for rpi5, so its evaluated configuration is unchanged (compared on 16 app-independent facets: kernel, params, initrd modules, loader, device tree, video drivers, udev, filesystems, swap, nix settings, sleep targets, service exec/memory, env seed, sshd). No new board yet — that's the next commit. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_013A6683cCHnQxFUosx1krY4 --- flake.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 705fd4c..ab640f7 100644 --- a/flake.nix +++ b/flake.nix @@ -308,14 +308,26 @@ fiatCode = fiatCodeForModel.${machineModel} or "USD"; }; + # Supported Pi boards, keyed by machine model. Each pairs the + # nixos-hardware board module (kernel, firmware, bootloader, device tree) + # with our own hardware glue (validator serial, kiosk display, no-suspend). + # Everything else in the Pi runtime is board-agnostic. + piBoards = { + rpi5 = { + hardware = nixos-hardware.nixosModules.raspberry-pi-5; + glue = ./deploy/nixos/hardware/raspberry-pi-5.nix; + }; + }; + # Shared module list (everything EXCEPT the root fs and the sd-image # builder). atm-app/fiatCode are threaded in so both products share one # evaluated app closure. - piBaseModules = { machineModel, atm-app, fiatCode }: [ - nixos-hardware.nixosModules.raspberry-pi-5 + piBaseModules = { machineModel, atm-app, fiatCode }: + let board = piBoards.${machineModel}; in [ + board.hardware ./deploy/nixos/configuration.nix ./deploy/nixos/bitspire-atm.nix - ./deploy/nixos/hardware/raspberry-pi-5.nix + board.glue ({ config, lib, pkgs, pkgs-unstable, ... }: { services.bitspire = { enable = true;