-
my attempts to limit the CPU and Network resources used by Nix builds with the Nix Daemon…
-
tab-group: limiting resources used by nix builds
-
my attempts to limit the nix-daemon from: https://github.com/c2vi/nixos/blob/master/hosts/main.nix
# shedule nix builds with low priority, so the laptop is still usable while building something
nix.daemonCPUSchedPolicy = "idle";
nix.daemonIOSchedClass = "idle";
systemd.services.nix-daemon.serviceConfig.CPUSchedulingPolicy = lib.mkForce "idle";
systemd.services.nix-daemon.serviceConfig.IOSchedulingPriority = lib.mkForce "idle";
systemd.services.nix-daemon.serviceConfig.CPUQuota = lib.mkForce "100%";
systemd.services.nix-daemon.serviceConfig.CPUWeight= lib.mkForce "idle";
systemd.services.nix-daemon.environment = {
LD_PRELOAD = "${pkgs.trickle}/lib/trickle/trickle-overload.so";
TRICKLE_WINDOW_SIZE = "200";
TRICKLE_UPLOAD_LIMIT = "10";
TRICKLE_LSMOOTH = "20";
TRICKLE_VERBOSE = "0";
TRICKLE_SOCKNAME = "";
TRICKLE_ARGV = "alacritty";
TRICKLE_TSMOOTH = "3.0";
TRICKLE_DOWNLOAD_LIMIT = "30";
};
nix.extraOptions = ''
download-speed = 30
'';
-
the serviceConfig does not make it into the
[Service]
section of${github:c2vi/nixos#top.main}/etc/systemd/system/nix-daemon.service
but rather${github:c2vi/nixos#top.main}/etc/systemd/system/nix-daemon.service.d/overrides.conf
… i thought there was a bug, that my serviceConfig was somehow ignored by NixOS… -
this has the service config as text:
nix eval '.#nixosConfigurations.main.config.systemd.units."nix-daemon.service".text' --raw
- also i used:
nix eval .#nixosConfigurations.main.config.environment.etc.systemd/system.source --impure
- also i used:
-
i tried trickle (pkg) to limit
-
the command to finally run the nix build (for the whole system-update) slowly while using the laptop:
sudo -E nix build .#top.main --impure --store / --option download-speed 30 --max-jobs 1 --cores 1 --option http-connections 1 --builders "$mosatop" -v
- rel: Run a Nix build without using the daemon
- the download-speed will get miltiplied by about 10 and it is in a large range around that times 10 value… WHYYYYYYYYYYYYYYYY… probably has smth todo with it starting multiple downloading connections (meaning the
--option http-connections 1
is just not working????) - you could also use systemd to limit cpu like so:
systemd-run -p IOSchedulingPriority=idle -p CPUWeight=idle -p CPUQuota=100% <rest-of-command>