Skip to content

[WIP] NixOS support#379

Open
mrosseel wants to merge 99 commits intobrickbots:mainfrom
mrosseel:nixos
Open

[WIP] NixOS support#379
mrosseel wants to merge 99 commits intobrickbots:mainfrom
mrosseel:nixos

Conversation

@mrosseel
Copy link
Collaborator

Summary

  • Full NixOS-based system for PiFinder (replaces Raspbian)
  • Declarative system configuration via Nix flake
  • SD card image, netboot, and migration bootstrap tarball builds
  • Software update via nixos-rebuild with GitHub release/PR channels

Test plan

  • Flash SD image and verify boot
  • Test WiFi AP and client mode switching
  • Test software update UI channels
  • Test hostname rename via web UI

🤖 Generated with Claude Code

mrosseel and others added 30 commits February 4, 2026 19:02
- build.yml: single build + Cachix push + unstable channel updates
- release.yml: manual release workflow for stable/beta channels

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The SD image module provides filesystems, but toplevel builds need
a minimal stub to evaluate successfully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Required for NixOS module system to accept devMode setting.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Required when module has both options and config sections.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replaces FIXME placeholders with actual SRI hashes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Uses Pi5 runner when RUNNER_LABELS variable is set, falls back to
ubuntu with QEMU emulation otherwise.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Filter to only Pi 4B device tree (CM4 incompatible with our overlays)
- Use shorthand DTS syntax for PWM overlay

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Untracked file was excluded from Nix flake source tree, causing
"No module named 'PiFinder.sys_utils_base'" on SD card boot.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add camera overlay (imx477) to netboot config.txt via flake.nix
- Fix sys_utils import in main.py to use utils.get_sys_utils()
- Add hip_main.dat fetch to pifinder-src.nix for starfield plotting
- Add dma_heap udev rule for libcamera/picamera2 access
- Fix shared memory naming in solver.py (remove leading /)
- Add DNS nameservers for netboot environment
- Document power control scripts in CLAUDE.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add runtimeCameraSelection option to hardware.nix (default: true)
- SD image includes config.txt with "include camera.txt" directive
- Users can edit camera.txt and reboot to switch cameras
- Supported cameras: imx296, imx290 (imx462), imx477
- Fix cameraDriver scope in hardware.nix (moved to top-level let)
- Add sudoers rules for systemctl stop/start pifinder.service
- Add DMA heap udev rule for libcamera video group access
- Netboot config sets cameraType = "imx477" for HQ camera dev

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Refactor sys_utils modules to use common base class
- Add sys_utils_nixos.py for NixOS-specific implementations
- Add get_sys_utils() detection in utils.py for platform selection
- Add flake.lock for reproducible builds
- Add NetworkManager config to networking.nix
- Add deploy-image-to-nfs.sh for netboot development workflow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update build.yml CI workflow
- Fix fonts.py import
- Fix marking_menus.py formatting
- Add missing import to preview.py
- Simplify objects_db.py
- Add catalog_imports improvements
- Update pifinder_objects.db

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Switch to NFSv4 with caching disabled (noac, actimeo=0)
- Disable auto-optimise-store in devMode (hard links fail on NFS)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ServerAliveInterval/CountMax to prevent timeout during transfers
- Use rsync -R (relative) to preserve directory structure correctly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comets.txt is downloaded at runtime and must be in a writable
location, not the read-only Nix store.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extend eth0 wait to 30 seconds with debug output
- Wait for link carrier before DHCP
- Add DHCP retries (3 attempts)
- Add LIBCAMERA_IPA_MODULE_PATH to pifinder service environment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Restore SUBSYSTEM=="pwm" udev rule that was accidentally removed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Turns on keypad LEDs during sysinit for early visual boot feedback.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- boot-splash.c: displays welcome image with scanning animation
- Starts at sysinit, stops when pifinder.service starts
- Much faster than Python splash

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove nixos-hardware module (saves 659MB linux-firmware)
- Fetch nixos-rebuild at runtime (saves ~500MB llvm/nix deps)
- Remove git from systemPackages (nix has built-in git for flakes)

Target: ~150MB vs current 1.7GB
- Remove default packages (vim, nano, etc)
- Disable polkit, udisks2, speechd
- Should reduce closure significantly
NetworkManager-vpnc alone has 1.1GB closure (webkitgtk, llvm, etc).
Disable all NM plugins for bootstrap - we just need WiFi.
mrosseel and others added 10 commits February 13, 2026 04:01
Replace nixos-rebuild with direct nix store path deployment:
- CI builds push to Cachix and stamp pifinder-build.json per branch
- Upgrade service uses nix copy + switch-to-configuration (no OOM)
- Software UI resolves store paths from per-branch build metadata
- Delete versions.json (replaced by pifinder-build.json)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nix copy --from uses only the specified source store. If Cachix
doesn't have every transitive dependency (e.g. shadow from nixos
cache), the copy fails. nix build with --max-jobs 0 uses all
configured substituters (Cachix + cache.nixos.org) as fallbacks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rename nox.yml to lint.yml, use nix develop for ruff/mypy/pytest
- Move ruff builtins config into pyproject.toml, target py313
- Add notebook lint exclusions (E402, F841)
- Fix ambiguous variable name in software.py (l -> lbl)
- Remove unused import in sys_utils.py
- Delete noxfile.py, requirements.txt, requirements_dev.txt
- Add DEPENDENCIES.md (auto-generated from nix) and generation script
- Update .pre-commit-config.yaml with ruff lint+format hooks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
native-wait job polls build-native for 15 min on ubuntu-latest.
If the self-hosted aarch64 runner doesn't pick up the job in time,
build-emulated kicks in with QEMU instead of queuing forever.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add openFirewall = true to samba service
- Remove manual port 22 (openssh.openFirewall defaults to true)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
github-actions bot and others added 17 commits February 13, 2026 11:24
Avahi fails to start after switch-to-configuration because the old
PID file persists at /run/avahi-daemon/pid. Add ExecStartPre to
remove it, preventing mDNS (pifinder.local) from breaking on upgrades.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DeterminateSystems/nix-installer-action defaults to determinate: true
which requires FlakeHub auth. This fails on forks (brickbots/PiFinder)
because OIDC tokens don't work cross-repo. Use upstream Nix instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Validate hostnames (DNS-safe: alphanumeric + hyphens, max 63 chars)
- Add sudo to avahi-set-host-name call with fallback to restart avahi
- Add avahi-set-host-name to sudoers NOPASSWD rules
- Add avahi restart fallback to pifinder-hostname boot service
- Replace hardcoded 128x128 in status.py with display class constants

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
switch-to-configuration stops changed services, which kills the
pifinder-upgrade service mid-switch. Move activation (test, health
check, bootloader persist, cleanup) into a systemd-run scope that
survives the service being stopped.

Poll /run/pifinder/upgrade-status file instead of relying solely on
systemctl is-active, which falsely reported failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The systemd-run --scope approach failed — switch-to-configuration
deactivated the transient scope during daemon-reload. Instead, set
restartIfChanged=false and stopIfChanged=false on pifinder-upgrade
so it survives switch-to-configuration without being killed.

Also add granular upgrade phases (downloading, activating, verifying,
persisting) to the status file for future progress display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Compares top-level keys in default_config.json between base and head
on pull requests. Emits ::warning:: annotations for any removed keys
to catch accidental breakage of user preferences across releases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
version.txt was manually maintained and redundant. Now:
- CI stamps branch-sha as version for non-release builds
- Release workflow already sets version from input
- Python reads version from pifinder-build.json via utils.get_version()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This function was never called in production code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Multiple queued runs for the same branch compete for the single
self-hosted runner and can stall the GitHub Actions dispatcher.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Save the unlock state to config so users don't have to tap
square 7 times after every reboot.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mrosseel mrosseel added testable Ready for testing via PiFinder software update and removed testable Ready for testing via PiFinder software update labels Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testable Ready for testing via PiFinder software update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant