Hybrid cloud cluster monorepo with Ansible, K8s, NixOS, and Terraform. cute.haus
ansible terraform nix k8s
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(b2-mounts): replace systemd.mounts list with drop-in unit overrides

Two bugs found by Claude Code review:

1. systemd.mounts is typed as a list, not an attrset — the foldl' attrset
construct would fail at eval time. Even if fixed, declaring a mount
in systemd.mounts shadows the fileSystems-generated unit, but our
entry omitted what/type/options so the shadow would be broken.

Fix: use systemd.units."<name>.mount" with overrideStrategy =
"asDropin". This writes /etc/systemd/system/<unit>.d/override.conf
which merges into the fileSystems-generated unit cleanly.

2. Health check mountpoint -q doesn't detect stale FUSE mounts (kernel
retains the mountpoint even after rclone dies, returning ENOTCONN).

Fix: add a timeout 10 ls $path check. On stale mount, lazy-unmount
with umount -l before resetting and restarting the unit.

Aly Raffauf (Jul 9, 2026, 9:39 PM EDT) 0a1cd625 b54b2bd2

+22 -6
+22 -6
nix/nixos/profiles/b2-mounts.nix
··· 99 99 cfg.shares)) 100 100 allShares)); 101 101 102 - systemd.mounts = 102 + # Drop-in overrides: remove the StartLimitBurst cap so automount 103 + # retries indefinitely after a transient network failure. 104 + # These merge into the fileSystems-generated mount units without 105 + # redefining them. 106 + systemd.units = 103 107 builtins.foldl' (a: b: a // b) {} 104 108 (map (share: { 105 - "/mnt/Backblaze/${share}" = { 109 + "mnt-Backblaze-${share}.mount" = { 110 + overrideStrategy = "asDropin"; 106 111 unitConfig = { 107 112 StartLimitIntervalSec = "0"; 108 113 }; ··· 110 115 }) cfg.shares); 111 116 112 117 systemd.services.b2-mount-health = let 118 + # Bash will iterate over cfg.shares — names are enum-constrained 119 + # so no spaces or special characters are possible. 113 120 healthScript = pkgs.writeShellScript "b2-mount-health" '' 114 121 for share in ${toString cfg.shares}; do 115 - if ! mountpoint -q "/mnt/Backblaze/$share"; then 116 - systemctl reset-failed "mnt-Backblaze-$share.mount" "mnt-Backblaze-$share.automount" 117 - systemctl start "mnt-Backblaze-$share.mount" || true 122 + path="/mnt/Backblaze/$share" 123 + unit="mnt-Backblaze-$share" 124 + if ! mountpoint -q "$path"; then 125 + # Not mounted at all — reset and retry 126 + systemctl reset-failed "$unit.mount" "$unit.automount" 2>/dev/null || true 127 + systemctl start "$unit.mount" || true 128 + elif ! timeout 10 ls "$path" >/dev/null 2>&1; then 129 + # Mounted but stale (rclone process died, kernel has ENOTCONN) 130 + # Lazy-unmount to clear the dead session, then restart 131 + umount -l "$path" 2>/dev/null || true 132 + systemctl reset-failed "$unit.mount" "$unit.automount" 2>/dev/null || true 133 + systemctl start "$unit.mount" || true 118 134 fi 119 135 done 120 136 ''; 121 137 in { 122 - description = "B2 FUSE mount health check — restarts failed mounts"; 138 + description = "B2 FUSE mount health check — restarts failed or stale mounts"; 123 139 after = ["network-online.target"]; 124 140 wants = ["network-online.target"]; 125 141 serviceConfig.Type = "oneshot";