diff --git a/modules/nixos/hardware/fs.nix b/modules/nixos/hardware/fs.nix --- a/modules/nixos/hardware/fs.nix +++ b/modules/nixos/hardware/fs.nix @@ -1,26 +1,17 @@ -{ lib, config, ... }: -let - inherit (lib) mkIf mkMerge filterAttrs; - - hasBtrfs = (filterAttrs (_: v: v.fsType == "btrfs") config.fileSystems) != { }; -in +{ config, ... }: { - config = mkMerge [ - { - # discard blocks that are not in use by the filesystem, good for SSDs health - services.fstrim = { - enable = true; - interval = "weekly"; - }; - } + # discard blocks that are not in use by the filesystem, good for SSDs health + services = { + fstrim = { + enable = true; + interval = "weekly"; + }; # clean btrfs devices - (mkIf hasBtrfs { - services.btrfs.autoScrub = { - enable = true; - interval = "weekly"; - fileSystems = [ "/" ]; - }; - }) - ]; + btrfs.autoScrub = { + enable = config.boot.supportedFilesystems.btrfs or false; + interval = "weekly"; + fileSystems = [ "/" ]; + }; + }; }