2023-06-05 15:50:07 +00:00
|
|
|
{ lib
|
|
|
|
, config
|
|
|
|
, pkgs
|
2023-08-12 23:21:32 +00:00
|
|
|
, inputs
|
2023-06-05 15:50:07 +00:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
gcc-system-features = arch: lib.optionals (arch != null) ([ "gccarch-${arch}" ]
|
|
|
|
++ map (x: "gccarch-${x}") lib.systems.architectures.inferiors.${arch});
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
simd.arch = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
Microarchitecture string for nixpkgs.hostPlatform.gcc.march and to generate system-features.
|
|
|
|
Can be determined with: gcc -march=native -Q --help=target | grep march
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
imports = [ ./builder.nix ];
|
|
|
|
|
|
|
|
config = {
|
|
|
|
warnings = lib.optionals (config.simd.arch == null) [ "Please set simd.arch for ${config.networking.hostName}" ];
|
2023-07-01 11:00:27 +00:00
|
|
|
# Allow more open files for non-root users to run NixOS VM tests.
|
|
|
|
security.pam.loginLimits = [
|
|
|
|
{ domain = "*"; item = "nofile"; type = "-"; value = "20480"; }
|
|
|
|
];
|
2023-06-05 15:50:07 +00:00
|
|
|
|
2024-05-20 15:39:23 +00:00
|
|
|
# Makes the computer go faster.
|
2024-06-08 10:27:43 +00:00
|
|
|
# nixos.jobserver.enable = true;
|
|
|
|
# TODO(raito): rework this.
|
2024-05-20 15:39:23 +00:00
|
|
|
|
2024-06-08 10:23:57 +00:00
|
|
|
# Avoid weird failures for builders.
|
|
|
|
services.openssh.settings.MaxStartups = 100;
|
|
|
|
|
2023-08-12 23:21:32 +00:00
|
|
|
# Memory accounting techniques
|
|
|
|
systemd.services.nix-daemon.serviceConfig = {
|
|
|
|
MemoryAccounting = true;
|
|
|
|
MemoryMax = "225G";
|
|
|
|
MemoryHigh = "220G";
|
|
|
|
MemorySwapMax = "2G";
|
|
|
|
ManagedOOMSwap = "kill";
|
|
|
|
ManagedOOMMemoryPressure = "kill";
|
|
|
|
MemoryPressureWatch = "on";
|
|
|
|
};
|
|
|
|
|
2023-06-05 15:50:07 +00:00
|
|
|
nix = {
|
2023-07-01 11:00:27 +00:00
|
|
|
# Garbage-collect often
|
2023-06-05 15:50:07 +00:00
|
|
|
gc.automatic = true;
|
2023-07-01 11:00:27 +00:00
|
|
|
gc.dates = "*:45";
|
|
|
|
gc.options = ''--max-freed "$((128 * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | ${pkgs.gawk}/bin/awk '{ print $4 }')))"'';
|
|
|
|
|
|
|
|
# Randomize GC to avoid thundering herd effects.
|
|
|
|
gc.randomizedDelaySec = "1800";
|
2023-06-05 15:50:07 +00:00
|
|
|
|
2024-08-22 16:23:53 +00:00
|
|
|
# A much better choice.
|
2024-09-27 11:07:31 +00:00
|
|
|
# Raito: We use this machine as a testing bed for cutting edge Lix features.
|
|
|
|
package = inputs.lix.packages.x86_64-linux.default;
|
2023-06-05 15:50:07 +00:00
|
|
|
|
|
|
|
# should be enough?
|
2023-08-03 20:56:37 +00:00
|
|
|
nrBuildUsers = 128;
|
2023-06-05 15:50:07 +00:00
|
|
|
|
|
|
|
settings = {
|
2024-01-27 18:13:13 +00:00
|
|
|
keep-outputs = false;
|
|
|
|
keep-derivations = false;
|
2023-08-12 23:21:32 +00:00
|
|
|
use-cgroups = true;
|
|
|
|
http-connections = 0;
|
|
|
|
auto-allocate-uids = true;
|
2024-05-20 15:39:23 +00:00
|
|
|
cores = 0;
|
2023-08-12 23:21:32 +00:00
|
|
|
max-jobs = 2; # Do not build more than 2 derivations at once in the event, both of them are too big, yes this is stupid, fix it in Nix.
|
|
|
|
fsync-metadata = true;
|
2023-06-05 15:50:07 +00:00
|
|
|
substituters = [
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
"https://tum-dse.cachix.org"
|
|
|
|
];
|
|
|
|
system-features = [ "benchmark" "big-parallel" "kvm" "nixos-test" ] ++ gcc-system-features config.simd.arch;
|
|
|
|
trusted-public-keys = [
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
"tum-dse.cachix.org-1:v67rK18oLwgO0Z4b69l30SrV1yRtqxKpiHodG4YxhNM="
|
|
|
|
];
|
2023-08-12 23:21:32 +00:00
|
|
|
experimental-features = [
|
|
|
|
"auto-allocate-uids"
|
2024-01-27 18:13:13 +00:00
|
|
|
# "ca-derivations" this feature is really extremely broken.
|
2023-08-12 23:21:32 +00:00
|
|
|
"cgroups"
|
|
|
|
"fetch-closure"
|
|
|
|
"impure-derivations"
|
|
|
|
];
|
2023-06-05 15:50:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
};
|
|
|
|
}
|