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 # Reduce SD card writes - logs to tmpfs
21 services.journald.extraConfig = ''
22 Storage=volatile
23 RuntimeMaxUse=64M
24 '';
25
26 # tmpfs for /tmp to avoid SD wear
27 boot.tmp.useTmpfs = true;
28 boot.tmp.tmpfsSize = "64M";
29 };
30}