2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.fstrim;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fstrim = {
|
|
|
|
enable = mkEnableOption "periodic SSD TRIM of mounted partitions in background";
|
|
|
|
|
|
|
|
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 = {
|
|
|
|
OnCalendar = cfg.interval;
|
|
|
|
};
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
meta.maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|