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 "periodic SSD TRIM of mounted partitions in background";
15
16 interval = mkOption {
17 type = types.string;
18 default = "weekly";
19 description = ''
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 <citerefentry><refentrytitle>systemd.time</refentrytitle>
25 <manvolnum>7</manvolnum></citerefentry>.
26 '';
27 };
28 };
29
30 };
31
32 config = mkIf cfg.enable {
33
34 systemd.packages = [ pkgs.utillinux ];
35
36 systemd.timers.fstrim = {
37 timerConfig = {
38 OnCalendar = cfg.interval;
39 };
40 wantedBy = [ "timers.target" ];
41 };
42
43 };
44
45 meta.maintainers = with maintainers; [ gnidorah ];
46}