2017-05-30 13:39:27 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.fstrim;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fstrim = {
|
2022-08-28 19:18:44 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "periodic SSD TRIM of mounted partitions in background");
|
2017-05-30 13:39:27 +00:00
|
|
|
|
|
|
|
interval = mkOption {
|
2019-08-08 20:48:27 +00:00
|
|
|
type = types.str;
|
2017-05-30 13:39:27 +00:00
|
|
|
default = "weekly";
|
2022-08-05 17:39:00 +00:00
|
|
|
description = lib.mdDoc ''
|
2017-05-30 13:39:27 +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-05 17:39:00 +00:00
|
|
|
{manpage}`systemd.time(7)`.
|
2017-05-30 13:39:27 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-11-24 15:29:28 +00:00
|
|
|
systemd.packages = [ pkgs.util-linux ];
|
2017-05-30 13:39:27 +00:00
|
|
|
|
|
|
|
systemd.timers.fstrim = {
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = cfg.interval;
|
|
|
|
};
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-04-29 05:21:13 +00:00
|
|
|
meta.maintainers = with maintainers; [ ];
|
2017-05-30 13:39:27 +00:00
|
|
|
}
|