# https://nix.dev/tutorials/nixos/distributed-builds-setup.html { config, ... }: { users.users.remotebuild = { isSystemUser = true; group = "remotebuild"; useDefaultShell = true; openssh.authorizedKeys.keys = config.users.users.root.openssh.authorizedKeys.keys; }; users.groups.remotebuild = { }; nix = { nrBuildUsers = 64; # defaults to 32 settings = { trusted-users = [ "remotebuild" ]; min-free = 50 * 1024 * 1024 * 1024; # start gc when < 10 GB is available max-free = 100 * 1024 * 1024 * 1024; # stop gc when 20 GB is available max-jobs = "auto"; cores = 0; }; }; systemd.services.nix-daemon.serviceConfig = { MemoryAccounting = true; MemoryMax = "90%"; OOMScoreAdjust = 500; }; }