2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.fstrim;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fstrim = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "periodic SSD TRIM of mounted partitions in background");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
interval = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "weekly";
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
How often we run fstrim. For most desktop and server systems
|
|
|
|
a sufficient trimming frequency is once a week.
|
|
|
|
|
|
|
|
The format is described in
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.time(7)`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-11-24 20:58:05 +00:00
|
|
|
systemd.packages = [ pkgs.util-linux ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
systemd.timers.fstrim = {
|
|
|
|
timerConfig = {
|
2023-05-24 13:37:59 +00:00
|
|
|
OnCalendar = [ "" cfg.interval ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
meta.maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|