diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-15 21:59:24 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-16 17:49:39 +0200 |
| commit | 0b4eaa6156f03814a1bf204a62f17d66a96e07b2 (patch) | |
| tree | f8b01ed24e690e01fb60838def8d6aa62ae3b7e7 /hosts/by-name/tiamat/legacy-disk-module/fstrim.nix | |
| parent | pkgs/sw: Support a nix specific swallow mode (diff) | |
| download | nixos-config-0b4eaa6156f03814a1bf204a62f17d66a96e07b2.zip | |
Otherwise, I would need to also re-deploy tiamat, which seems not like a
useful approach.
Diffstat (limited to 'hosts/by-name/tiamat/legacy-disk-module/fstrim.nix')
| -rw-r--r-- | hosts/by-name/tiamat/legacy-disk-module/fstrim.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/hosts/by-name/tiamat/legacy-disk-module/fstrim.nix b/hosts/by-name/tiamat/legacy-disk-module/fstrim.nix new file mode 100644 index 00000000..0fbb6c83 --- /dev/null +++ b/hosts/by-name/tiamat/legacy-disk-module/fstrim.nix @@ -0,0 +1,51 @@ +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. +{ + pkgs, + lib, + cfg, +}: { + timers.fstrim = lib.mkIf cfg.ssd { + wantedBy = ["timers.target"]; + wants = ["fstrim.service"]; + unitConfig = { + Description = "Discard unused blocks once a week"; + Documentation = "man:fstrim"; + ConditionVirtualization = "!container"; + ConditionPathExists = "!/etc/initrd-release"; + }; + timerConfig = { + OnCalendar = "weekly"; + AccuracySec = "1h"; + Persistent = "true"; + RandomizedDelaySec = "6000"; + }; + }; + services.fstrim = lib.mkIf cfg.ssd { + wantedBy = lib.mkForce []; + unitConfig = { + Description = "Discard unused blocks on filesystems from /etc/fstab"; + Documentation = "man:fstrim(8)"; + ConditionVirtualization = "!container"; + }; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.util-linux}/bin/fstrim --listed-in /etc/fstab:/proc/self/mountinfo --verbose --quiet-unsupported"; + PrivateDevices = "no"; + PrivateNetwork = "yes"; + PrivateUsers = "no"; + ProtectKernelTunables = "yes"; + ProtectKernelModules = "yes"; + ProtectControlGroups = "yes"; + MemoryDenyWriteExecute = "yes"; + SystemCallFilter = "@default @file-system @basic-io @system-service"; + }; + }; +} |
