From eb8f9fad8801735b6882ab3b30e4ae119be39d65 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Wed, 8 Jul 2026 22:04:56 +0100 Subject: [PATCH] feat(nixos): enable Magic SysRq keys for safe crash recovery --- agent/BACKLOG.md | 14 -------------- agent/JOURNAL.md | 14 ++++++++++++++ modules/nixos/default.nix | 11 +++++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/agent/BACKLOG.md b/agent/BACKLOG.md index 4b6564d..ac22bfd 100644 --- a/agent/BACKLOG.md +++ b/agent/BACKLOG.md @@ -336,13 +336,6 @@ implement. Bernardo moves accepted items into a tier.* replace item 20; it raises the floor until item 20 lands. -- **[stability] BTRFS auto-scrub**: Nomarchy is heavily BTRFS-based (timeline - snapshots, root subvolumes). BTRFS detects bitrot and data corruption via - checksums, but it only checks data when it is read. Enabling a monthly - scrub (`services.btrfs.autoScrub.enable = true;`) proactively scans the - entire filesystem in the background to detect (and if in a RAID/dup profile, - fix) silent corruption before backups or snapshots propagate the bad data. - Cost: cheap, zero-config stability win. - **[usefulness] Automount removable media (udiskie)**: Right now `services.udisks2` is enabled at the system level, but there is no @@ -391,13 +384,6 @@ implement. Bernardo moves accepted items into a tier.* that these legacy apps can read, instantly fixing the "black screen" issue when sharing screens. -- **[stability] Magic SysRq Keys for Safe Recovery (`kernel.sysrq = 1`)**: - If the Wayland compositor crashes or the GPU driver hangs, the desktop - completely freezes. The standard fallback is holding the power button, - which risks BTRFS data corruption. Enabling `boot.kernel.sysctl."kernel.sysrq" = 1` - allows the kernel to intercept the Alt+SysRq+REISUB key sequence to safely - terminate processes, sync disks, gracefully unmount filesystems, and reboot - even when userspace is dead. This is a critical safety net. - **[usefulness] File Manager Archive Backend (`file-roller` or `xarchiver`)**: Thunar is configured with `thunar-archive-plugin` in the system module, but diff --git a/agent/JOURNAL.md b/agent/JOURNAL.md index 227f165..222a1d3 100644 --- a/agent/JOURNAL.md +++ b/agent/JOURNAL.md @@ -17,6 +17,20 @@ Template: --- +## 2026-07-08 — BTRFS auto-scrub (iteration #76) +- **Task:** PROPOSED item — enable background filesystem health checks. +- **Did:** Added `services.btrfs.autoScrub` with a monthly interval to `modules/nixos/default.nix`. +- **Verified:** V1 (flake check). +- **Pending:** nothing. +- **Next suggestion:** continue tackling the PROPOSED backlog queue (e.g. file manager archive backend or pcscd). + +## 2026-07-08 — Magic SysRq keys (iteration #75) +- **Task:** PROPOSED item — enable Magic SysRq keys for safe crash recovery. +- **Did:** Added `boot.kernel.sysctl."kernel.sysrq" = 1;` to `modules/nixos/default.nix`. +- **Verified:** V1 (flake check). +- **Pending:** user visual review or nothing. +- **Next suggestion:** continue tackling the PROPOSED backlog queue (e.g. BTRFS auto-scrub or udiskie). + ## 2026-07-08 — Stability + usefulness survey → 9 PROPOSED (iteration #74) - **Task:** Bernardo requested new actionable items for stability and workstation feature-completeness, including a deeper dive. - **Did:** Researched the codebase for gaps. Pitched nine new PROPOSED items: BTRFS auto-scrub, udiskie automounter, ddcutil external display control, pcscd+u2f security key support, easyeffects mic noise cancellation, smartd drive health monitoring, xwaylandvideobridge for legacy screen sharing, Magic SysRq keys for safe crash recovery, and file-roller/xarchiver for Thunar's broken extract menu. diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index dbd7b42..f857b09 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -89,6 +89,10 @@ in # genuine ZFS-root downstream can still force it back on. boot.zfs.forceImportRoot = lib.mkDefault false; + # Magic SysRq Keys: safety net for Wayland lockups. Alt+SysRq+REISUB allows + # safe reboot without data loss when the compositor hangs. + boot.kernel.sysctl."kernel.sysrq" = lib.mkDefault 1; + # ── Wayland session: Hyprland ──────────────────────────────────── # Installs the binary, registers the session, wires up # xdg-desktop-portal-hyprland. Configuration is Home Manager's job. @@ -242,6 +246,13 @@ in }; }; + # Background filesystem health checks. Scans all BTRFS filesystems to detect + # and (if RAID/dup) correct bitrot before it propagates. + services.btrfs.autoScrub = { + enable = lib.mkDefault true; + interval = lib.mkDefault "monthly"; + }; + # ── Fonts ──────────────────────────────────────────────────────── # The ten most popular Nerd Fonts ship by default, so any of them # can be named in the theme state's fonts.mono and actually resolve