From 255cb34846a426479ba0a3b38cd6f66a4b11718d Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 25 Mar 2024 13:41:31 +0100 Subject: [PATCH] Limit resource usage when performing upgrades --- configuration.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/configuration.nix b/configuration.nix index 868a4fa..f5e39e1 100644 --- a/configuration.nix +++ b/configuration.nix @@ -180,13 +180,17 @@ with pkgs; system.autoUpgrade = { enable = true; flake = "/home/coolneng/system"; - flags = [ - "--update-input" - "agenix" - "--update-input" - "nixpkgs" - "--commit-lock-file" - ]; + flags = + [ "--update-input agenix --update-input nixpkgs" "--commit-lock-file" ]; + }; + + # Limit the memory and CPU use of Nix + systemd.services.nixos-upgrade.serviceConfig = { + MemoryHigh = [ "500M" ]; + MemoryMax = [ "2048M" ]; + CPUWeight = [ "20" ]; + CPUQuota = [ "85%" ]; + IOWeight = [ "20" ]; }; # Configure git for auto-upgrade