nixpkgs/nixos/modules/services/misc/fstrim.nix

57 lines
923 B
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}:
2017-05-30 16:39:27 +03:00
let
cfg = config.services.fstrim;
in
{
2017-05-30 16:39:27 +03:00
options = {
services.fstrim = {
enable = (
lib.mkEnableOption "periodic SSD TRIM of mounted partitions in background"
// {
default = true;
}
);
2017-05-30 16:39:27 +03:00
interval = lib.mkOption {
type = lib.types.str;
2017-05-30 16:39:27 +03:00
default = "weekly";
description = ''
2017-05-30 16:39:27 +03: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
{manpage}`systemd.time(7)`.
2017-05-30 16:39:27 +03:00
'';
};
};
};
config = lib.mkIf cfg.enable {
2017-05-30 16:39:27 +03:00
2020-11-24 10:29:28 -05:00
systemd.packages = [ pkgs.util-linux ];
2017-05-30 16:39:27 +03:00
systemd.timers.fstrim = {
timerConfig = {
OnCalendar = [
""
cfg.interval
];
2017-05-30 16:39:27 +03:00
};
wantedBy = [ "timers.target" ];
};
};
meta.maintainers = [ ];
2017-05-30 16:39:27 +03:00
}