{ config, lib, ... }: let cfg = config.os.core.storage; in { options.os.core.storage = { enable = lib.mkEnableOption "enables storage management"; cleanDates = lib.mkOption { type = lib.types.int; default = "weekly"; description = "how often to clean the system of old generations"; }; }; config = lib.mkIf cfg.enable { nix.settings.auto-optimise-store = true; programs.nh = { enable = true; clean = { enable = true; dates = "${toString cfg.cleanDates}"; clean.extraArgs = "--keep 5"; }; }; services.fstrim.enable = true; services.btrfs.autoScrub = { enable = true; fileSystems = [ "/" ]; }; boot.tmp = { useTmpfs = true; tmpfsSize = "50%"; }; }; }