1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 cfg = config.services.fstrim;
8
9in {
10
11 options = {
12
13 services.fstrim = {
14 enable = mkEnableOption (lib.mdDoc "periodic SSD TRIM of mounted partitions in background");
15
16 interval = mkOption {
17 type = types.str;
18 default = "weekly";
19 description = lib.mdDoc ''
20 How often we run fstrim. For most desktop and server systems
21 a sufficient trimming frequency is once a week.
22
23 The format is described in
24 {manpage}`systemd.time(7)`.
25 '';
26 };
27 };
28
29 };
30
31 config = mkIf cfg.enable {
32
33 systemd.packages = [ pkgs.util-linux ];
34
35 systemd.timers.fstrim = {
36 timerConfig = {
37 OnCalendar = [ "" cfg.interval ];
38 };
39 wantedBy = [ "timers.target" ];
40 };
41
42 };
43
44 meta.maintainers = with maintainers; [ ];
45}