{ config, lib, ... }: let cfg = config.my.fs; in { config = lib.mkIf (cfg.type == "btrfs") { fileSystems = builtins.mapAttrs (_: options: { inherit (cfg) device; fsType = "btrfs"; options = [ "noatime" "space_cache=v2" "compress=zstd:9" ] ++ options ++ lib.optional config.services.fstrim.enable "nodiscard"; }) ({ "/" = [ "subvol=root" ]; "/nix" = [ "subvol=nix" ]; "/home" = [ "subvol=home" ]; } // lib.optionalAttrs cfg.snapshots { "/home/${config.my.user.username}/.cache" = [ "subvol=misc/cache" ]; "/home/${config.my.user.username}/no-snapshot" = [ "subvol=misc/other" ]; }); services = { snapper = lib.mkIf cfg.snapshots { configs.home = { SUBVOLUME = "/home"; ALLOW_USERS = [ config.my.user.username ]; TIMELINE_CREATE = true; TIMELINE_CLEANUP = true; }; }; }; }; }