diff options
author | sterni <sternenseemann@systemli.org> | 2023-11-26T11·54+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-11-26T22·16+0000 |
commit | 03d5ffd2ded360341a024dd796a8b27680cfb037 (patch) | |
tree | 84348eae3dda4a95eb00ce64e500be80b0962014 /ops/modules/btrfs-auto-scrub.nix | |
parent | 825b6ac65f69737bbcba99058433e0af3fcc33b7 (diff) |
feat(sterni/ingeborg): enable btrfs auto scrub r/7070
While we are at it, rename disk-checkup.nix to btrfs-auto-scrub.nix and move it into //ops/modules. I originally wanted to have additionally disk health related services in that module, but the btrfs scrub functionality is nicely self-contained and reusable, so I think it makes sense to have this in a more central location. Change-Id: Iabdd62838eef009540ca71abafd921afda2a9b47 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10128 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'ops/modules/btrfs-auto-scrub.nix')
-rw-r--r-- | ops/modules/btrfs-auto-scrub.nix | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ops/modules/btrfs-auto-scrub.nix b/ops/modules/btrfs-auto-scrub.nix new file mode 100644 index 000000000000..b073efa3dfd1 --- /dev/null +++ b/ops/modules/btrfs-auto-scrub.nix @@ -0,0 +1,25 @@ +# Automatically performs a scrub on all btrfs filesystems configured in +# `config.fileSystems` on a daily schedule (by default). Activated by importing. +{ config, lib, ... }: + +{ + config = { + services = { + btrfs.autoScrub = { + enable = true; + interval = lib.mkDefault "daily"; + # gather all btrfs fileSystems, extra ones can be added via the NixOS + # module merging mechanism, of course. + fileSystems = lib.concatLists ( + lib.mapAttrsToList + ( + _: + { fsType, mountPoint, ... }: + if fsType == "btrfs" then [ mountPoint ] else [ ] + ) + config.fileSystems + ); + }; + }; + }; +} |