2022-09-04 01:59:56 -04:00
|
|
|
{ config, lib, pkgs, inputs, ... }@attrs:
|
2022-10-13 22:13:43 -04:00
|
|
|
with lib; {
|
2022-09-04 01:59:56 -04:00
|
|
|
config = mkMerge [
|
2022-10-13 22:13:43 -04:00
|
|
|
(mkIf pkgs.stdenv.isLinux {
|
|
|
|
zramSwap = mkIf config.nathan.services.zramSwap {
|
|
|
|
enable = true;
|
|
|
|
algorithm = "lz4";
|
|
|
|
memoryPercent = 25;
|
|
|
|
};
|
|
|
|
nix = mkIf config.nathan.config.nix.autoGC { autoOptimiseStore = true; };
|
|
|
|
})
|
|
|
|
(mkIf config.nathan.config.harden
|
|
|
|
(import "${inputs.nixpkgs}/nixos/modules/profiles/hardened.nix" attrs))
|
2022-09-04 01:59:56 -04:00
|
|
|
(mkIf config.nathan.config.harden {
|
|
|
|
boot.kernelPackages = pkgs.linuxPackages_5_18_hardened;
|
|
|
|
security = {
|
|
|
|
allowSimultaneousMultithreading = true;
|
|
|
|
unprivilegedUsernsClone = true;
|
|
|
|
};
|
|
|
|
})
|
2022-10-13 22:13:43 -04:00
|
|
|
(mkIf ((!config.nathan.config.harden) && config.nathan.config.isDesktop) {
|
2022-09-04 01:59:56 -04:00
|
|
|
# Use the zen kernel with muqss turned on
|
2022-10-13 22:13:43 -04:00
|
|
|
boot.kernelPackages = let
|
|
|
|
linuxZenWMuQSS = pkgs.linuxPackagesFor
|
|
|
|
(pkgs.linuxPackages_zen.kernel.override {
|
|
|
|
structuredExtraConfig = with lib.kernel; { SCHED_MUQSS = yes; };
|
2022-09-04 01:59:56 -04:00
|
|
|
ignoreConfigErrors = true;
|
2022-10-13 22:13:43 -04:00
|
|
|
});
|
|
|
|
in linuxZenWMuQSS;
|
|
|
|
})
|
|
|
|
(mkIf (config.nathan.config.nix.autoUpdate && pkgs.stdenv.isLinux) {
|
|
|
|
# Auto update daily at 2 am
|
|
|
|
system.autoUpgrade = {
|
|
|
|
enable = true;
|
|
|
|
allowReboot = true;
|
|
|
|
# Update from the flake
|
|
|
|
flake = "git+https://git.sr.ht/~thatonelutenist/system-flake?ref=trunk";
|
|
|
|
# Attempt to update daily at 2AM
|
|
|
|
dates = "2:00";
|
|
|
|
};
|
2022-09-04 01:59:56 -04:00
|
|
|
})
|
|
|
|
# Systemd user service cludge
|
|
|
|
{
|
|
|
|
systemd.user.extraConfig = ''
|
|
|
|
DefaultEnvironment="PATH=/run/current-system/sw/bin:/etc/profiles/per-user/${config.nathan.config.user}/bin"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|