1
0
Fork 0

System: replace weekly trim with continuous trim (SSDs)

This commit is contained in:
Aires 2024-08-24 12:39:04 -04:00
parent 21c3e5cb51
commit 442c39550d
2 changed files with 10 additions and 15 deletions

View file

@ -22,6 +22,11 @@ in
default = ""; default = "";
}; };
}; };
discard = lib.mkOption {
type = lib.types.bool;
description = "Whether to enable TRIM for SSD and NVMe drives. Defaults to true.";
default = true;
};
swapFile = { swapFile = {
enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of a swap file."); enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of a swap file.");
size = lib.mkOption { size = lib.mkOption {
@ -59,7 +64,7 @@ in
options = [ options = [
"subvol=@" "subvol=@"
"compress=zstd" "compress=zstd"
]; ] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
"/boot" = { "/boot" = {
device = cfg.partitions.boot; device = cfg.partitions.boot;
@ -71,7 +76,7 @@ in
options = [ options = [
"subvol=@home" "subvol=@home"
"compress=zstd" "compress=zstd"
]; ] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
"/var/log" = { "/var/log" = {
device = decryptPath; device = decryptPath;
@ -79,7 +84,7 @@ in
options = [ options = [
"subvol=@log" "subvol=@log"
"compress=zstd" "compress=zstd"
]; ] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
"/nix" = { "/nix" = {
device = decryptPath; device = decryptPath;
@ -88,7 +93,7 @@ in
"subvol=@nix" "subvol=@nix"
"compress=zstd" "compress=zstd"
"noatime" "noatime"
]; ] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
} }
// lib.optionalAttrs cfg.swapFile.enable { // lib.optionalAttrs cfg.swapFile.enable {
@ -98,7 +103,7 @@ in
options = [ options = [
"subvol=@swap" "subvol=@swap"
"noatime" "noatime"
]; ] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
}; };

View file

@ -53,16 +53,6 @@ in
# Enable fwupd (firmware updater) # Enable fwupd (firmware updater)
fwupd.enable = true; 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 # Allow systemd user services to keep running after the user has logged out
logind.killUserProcesses = false; logind.killUserProcesses = false;