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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
923 B
Nix
Raw Normal View History

2017-05-30 16:39:27 +03:00
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.fstrim;
in
{
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 = ''
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)`.
'';
};
};
};
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
}