me like nix
1{ ... }: {
2 flake.modules.nixos.pi-stability =
3 { lib, ... }:
4 {
5 # ZRAM swap to prevent OOM freezes
6 # Pi has limited RAM and continuous video streaming builds memory pressure
7 zramSwap = {
8 enable = true;
9 memoryPercent = 50;
10 };
11
12 # Hardware watchdog - automatically reboots on freeze
13 # Pi 4 and Zero 2W both have bcm2835 watchdog hardware
14 boot.kernelModules = [ "bcm2835_wdt" ];
15 systemd.watchdog = {
16 runtimeTime = "30s";
17 rebootTime = "60s";
18 };
19
20 # Persist logs so failures can be diagnosed after reboot.
21 services.journald.extraConfig = ''
22 Storage=persistent
23 SystemMaxUse=256M
24 RuntimeMaxUse=64M
25 '';
26
27 # tmpfs for /tmp to avoid SD wear
28 boot.tmp.useTmpfs = true;
29 boot.tmp.tmpfsSize = "64M";
30 };
31}