From 442c39550dbf9f3aecee88d3c35e1458b379623b Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 24 Aug 2024 12:39:04 -0400 Subject: [PATCH] System: replace weekly trim with continuous trim (SSDs) --- modules/system/filesystem.nix | 15 ++++++++++----- modules/system/system.nix | 10 ---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/system/filesystem.nix b/modules/system/filesystem.nix index 4091e13..991a951 100644 --- a/modules/system/filesystem.nix +++ b/modules/system/filesystem.nix @@ -22,6 +22,11 @@ in default = ""; }; }; + discard = lib.mkOption { + type = lib.types.bool; + description = "Whether to enable TRIM for SSD and NVMe drives. Defaults to true."; + default = true; + }; swapFile = { enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of a swap file."); size = lib.mkOption { @@ -59,7 +64,7 @@ in options = [ "subvol=@" "compress=zstd" - ]; + ] ++ lib.optionals cfg.discard [ "discard=async" ]; }; "/boot" = { device = cfg.partitions.boot; @@ -71,7 +76,7 @@ in options = [ "subvol=@home" "compress=zstd" - ]; + ] ++ lib.optionals cfg.discard [ "discard=async" ]; }; "/var/log" = { device = decryptPath; @@ -79,7 +84,7 @@ in options = [ "subvol=@log" "compress=zstd" - ]; + ] ++ lib.optionals cfg.discard [ "discard=async" ]; }; "/nix" = { device = decryptPath; @@ -88,7 +93,7 @@ in "subvol=@nix" "compress=zstd" "noatime" - ]; + ] ++ lib.optionals cfg.discard [ "discard=async" ]; }; } // lib.optionalAttrs cfg.swapFile.enable { @@ -98,7 +103,7 @@ in options = [ "subvol=@swap" "noatime" - ]; + ] ++ lib.optionals cfg.discard [ "discard=async" ]; }; }; diff --git a/modules/system/system.nix b/modules/system/system.nix index fdf9bdb..de6d6b5 100644 --- a/modules/system/system.nix +++ b/modules/system/system.nix @@ -53,16 +53,6 @@ in # Enable fwupd (firmware updater) fwupd.enable = true; - # Enable trim on supported drives - fstrim.enable = true; - - # Autoscrub BTRFS partitions - btrfs.autoScrub = lib.mkIf (config.fileSystems."/".fsType == "btrfs") { - enable = true; - interval = "weekly"; - fileSystems = [ "/" ]; - }; - # Allow systemd user services to keep running after the user has logged out logind.killUserProcesses = false;