diff --git a/docs/RASPBERRY_PI_SD_IMAGE.md b/docs/RASPBERRY_PI_SD_IMAGE.md index 167eb09..06126fe 100644 --- a/docs/RASPBERRY_PI_SD_IMAGE.md +++ b/docs/RASPBERRY_PI_SD_IMAGE.md @@ -49,7 +49,7 @@ Unlike btrfs-based hosts that use `/persist`, Pi hosts use `/nix/persist`: ```bash # Build SD image for stinky -nix build .#stinky-sdImage +nix build .#packages.aarch64-linux.stinky-sdImage # Result location ls -lh result/sd-image/ diff --git a/hosts/stinky/default.nix b/hosts/stinky/default.nix index 3303dc1..a49f613 100644 --- a/hosts/stinky/default.nix +++ b/hosts/stinky/default.nix @@ -7,16 +7,19 @@ { imports = [ ../../common/global - ../../common/impermanence-tmpfs.nix # Use tmpfs root with /nix/persist + ../../common/impermanence-common.nix # Impermanence with custom root config (see hardware.nix) ../../common/resource-limits.nix ../../common/sshd.nix ../../common/user-ppetru.nix - ../../common/systemd-boot.nix + # Note: No systemd-boot.nix - Raspberry Pi uses generic-extlinux-compatible (from sd-image module) ./hardware.nix ]; networking.hostName = "stinky"; + # Configure impermanence for tmpfs root (filesystem config in hardware.nix) + custom.impermanence.persistPath = "/nix/persist"; + # Tailscale configuration services.tailscaleAutoconnect.authkey = "PLACEHOLDER"; # Will be set in secrets @@ -35,7 +38,7 @@ environment.systemPackages = with pkgs; [ libcamera - raspberrypi-tools + libraspberrypi ]; # Firewall: Allow access to OctoPrint @@ -43,5 +46,6 @@ 5000 # OctoPrint ]; - system.stateVersion = "25.05"; + # Override global default (stinky is a new system with 25.05) + system.stateVersion = lib.mkForce "25.05"; } diff --git a/hosts/stinky/hardware.nix b/hosts/stinky/hardware.nix index bc1f8fd..c211b1e 100644 --- a/hosts/stinky/hardware.nix +++ b/hosts/stinky/hardware.nix @@ -13,25 +13,45 @@ # Raspberry Pi 4 platform nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; + # Disable ZFS (not needed, and broken with latest kernel) + boot.supportedFilesystems.zfs = lib.mkForce false; + # Boot configuration - provided by sd-image-aarch64.nix # (grub disabled, generic-extlinux-compatible enabled, U-Boot setup) - # Override root filesystem to use tmpfs (from impermanence-tmpfs.nix) - # The sd-image module sets root to /dev/disk/by-label/NIXOS_SD (ext4) - # but impermanence-tmpfs.nix overrides it to tmpfs - # /boot/firmware is automatically configured by sd-image module # Device: /dev/disk/by-label/FIRMWARE (vfat) - # Mount /nix from the NIXOS_SD partition - # /nix/persist will be a directory on this partition (not a separate mount) - fileSystems."/nix" = { + # tmpfs root with impermanence + # Override sd-image module's ext4 root definition with mkForce + fileSystems."/" = lib.mkForce { + device = "none"; + fsType = "tmpfs"; + options = [ + "defaults" + "size=2G" + "mode=755" + ]; + }; + + # The SD partition contains /nix/store and /nix/persist at its root + # Mount it at a hidden location, then bind mount its /nix to /nix + fileSystems."/mnt/nixos-sd" = { device = "/dev/disk/by-label/NIXOS_SD"; fsType = "ext4"; options = [ "noatime" ]; neededForBoot = true; }; + # Bind mount /nix from the SD partition + fileSystems."/nix" = { + device = "/mnt/nixos-sd/nix"; + fsType = "none"; + options = [ "bind" ]; + neededForBoot = true; + depends = [ "/mnt/nixos-sd" ]; + }; + # No swap on SD card (wear concern) swapDevices = [ ];