2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.fstrim;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fstrim = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "periodic SSD TRIM of mounted partitions in background";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
interval = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "weekly";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
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" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
meta.maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|