66 lines
1.6 KiB
Nix
Raw Permalink Normal View History

2021-10-26 01:04:15 +03:00
{ lib, pkgs, config, ... }:
with config.deviceSpecific; {
2022-01-30 02:10:32 +03:00
zramSwap = {
enable = true;
algorithm = "zstd";
2023-03-27 20:57:06 +03:00
priority = 100;
2023-04-16 18:59:54 +03:00
memoryPercent = 150; # around 50% of memory
2022-01-30 02:10:32 +03:00
};
2022-12-14 23:46:25 +03:00
persist.state.files = [ "/etc/machine-id" ];
2023-03-27 20:57:06 +03:00
services.earlyoom = {
enable = devInfo.ram < 16;
freeMemThreshold = 5;
freeSwapThreshold = 100;
};
services.fstrim = lib.mkIf (devInfo.fileSystem != "zfs") {
enable = isSSD;
interval = "weekly";
};
services.zfs = lib.mkIf (devInfo.fileSystem == "zfs") {
autoScrub.enable = true;
2023-11-22 05:57:58 +03:00
autoScrub.interval = "monthly";
2023-03-27 20:57:06 +03:00
trim.enable = isSSD;
trim.interval = "weekly";
};
boot = {
2021-02-07 02:38:11 +03:00
loader = {
2021-09-16 01:03:52 +03:00
timeout = lib.mkForce 4;
2023-03-27 20:57:06 +03:00
systemd-boot.enable = lib.mkDefault
pkgs.hostPlatform.system == "x86_64-linux";
2021-02-07 02:38:11 +03:00
};
2023-03-27 20:57:06 +03:00
kernelParams =
2025-02-20 14:46:48 +03:00
[ "zswap.enabled=0" "scsi_mod.use_blk_mq=1" "nofb" ]
2022-12-14 23:51:59 +03:00
++ lib.optionals (pkgs.hostPlatform.system == "x86_64-linux") [
2021-09-16 01:03:52 +03:00
"rd.systemd.show_status=auto"
"rd.udev.log_priority=3"
"pti=off"
"spectre_v2=off"
2022-02-11 14:07:03 +03:00
"kvm.ignore_msrs=1"
2023-04-25 17:24:01 +03:00
"kvm.report_ignored_msrs=0"
2021-09-16 01:03:52 +03:00
];
2024-06-03 04:05:33 +03:00
kernelPackages = lib.mkDefault pkgs.linuxPackages_lqx;
2021-02-07 02:38:11 +03:00
consoleLogLevel = 3;
2023-06-16 00:36:16 +03:00
kernel.sysctl = if config.zramSwap.enable then {
"vm.swappiness" = 100;
"vm.vfs_cache_pressure" = 500;
"vm.dirty_background_ratio" = 1;
"vm.dirty_ratio" = 50;
"vm.page-cluster" = 0;
} else {
2021-02-07 02:38:11 +03:00
"vm.swappiness" = if config.deviceSpecific.isSSD then 1 else 10;
};
2022-08-05 21:10:22 +03:00
2023-05-13 01:01:57 +03:00
tmp.cleanOnBoot = !config.boot.tmp.useTmpfs;
2023-03-27 20:57:06 +03:00
zfs.forceImportAll = lib.mkDefault false;
2023-09-16 02:04:05 +03:00
swraid.enable = false;
2021-02-07 02:38:11 +03:00
};
}