From 7d8f1572d1d400100b75076c5c9e9924a0c88f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 29 Sep 2024 14:03:30 +0200 Subject: [PATCH] nixos: enable fstrim by default The majority of users these days will install NixOS on SSD/NVME based storage. Enabling fstrim ensures that the TRIM operation on this type of storage is run at least once a week. This will improve performance and life time of said devices. This also works in virtual machines as formats such as qcow2 or vmdk support TRIM. Ubuntu has a similar systemd timer also for quite a while enabled by default. Enabling this service will not increase the dependency closure as util-linux is already part of the base system. In case only filesystems that are not supported by fstrim are used, the overhead is negelible as fstrim run in less than a second once a week. --- nixos/modules/services/misc/fstrim.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/fstrim.nix b/nixos/modules/services/misc/fstrim.nix index 8ead4a645f7c..f22505841fa3 100644 --- a/nixos/modules/services/misc/fstrim.nix +++ b/nixos/modules/services/misc/fstrim.nix @@ -8,7 +8,9 @@ in { options = { services.fstrim = { - enable = lib.mkEnableOption "periodic SSD TRIM of mounted partitions in background"; + enable = (lib.mkEnableOption "periodic SSD TRIM of mounted partitions in background" // { + default = true; + }); interval = lib.mkOption { type = lib.types.str;