mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-04 14:00:04 +00:00
nixos/nix-optimise: run with lower priority
It's painfully obvious to me on my anaemic system when `nix-optimise` kicks in, so run it with much lower priority since it's not time critical anyway. Additionally, do not run on battery power. I can appreciate that these are oppinionated defaults but I am having a hard imagining cases where this would be a show-stopper so there isn't much point in making this directly configurable via the nixos module system as people can always override the unit directly themselves via `systemd.services.nix-optimise`
This commit is contained in:
@@ -65,9 +65,17 @@ in
|
||||
systemd = lib.mkIf config.nix.enable {
|
||||
services.nix-optimise = {
|
||||
description = "Nix Store Optimiser";
|
||||
# No point this if the nix daemon (and thus the nix store) is outside
|
||||
unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
|
||||
serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise";
|
||||
unitConfig = {
|
||||
ConditionACPower = true;
|
||||
# No point this if the nix daemon (and thus the nix store) is outside
|
||||
ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
|
||||
};
|
||||
serviceConfig = {
|
||||
ExecStart = "${lib.getExe' config.nix.package "nix-store"} --optimise";
|
||||
Nice = 19;
|
||||
CPUSchedulingPolicy = "idle";
|
||||
IOSchedulingClass = "idle";
|
||||
};
|
||||
startAt = lib.optionals cfg.automatic cfg.dates;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user