[Nix+Optimizations] Fix distributed builds.

Also fix kernel and openssh if optimizations are turned off.
This commit is contained in:
Antoine Viallon 2022-10-08 21:22:14 +02:00
parent 52407e3f4e
commit 2f20fad072
Signed by: aviallon
GPG key ID: 186FC35EDEB25716
3 changed files with 18 additions and 14 deletions

View file

@ -153,7 +153,7 @@ in
kernelPatches = [] kernelPatches = []
++ optional cfg.x32abi.enable customKernelPatches.enableX32ABI ++ optional cfg.x32abi.enable customKernelPatches.enableX32ABI
++ optional cfg.rtGroupSched.enable customKernelPatches.enableRTGroupSched ++ optional cfg.rtGroupSched.enable customKernelPatches.enableRTGroupSched
++ optional config.aviallon.overlays.optimizations (customKernelPatches.optimizeForCPUArch config.aviallon.general.cpuArch) ++ optional config.aviallon.optimizations.enable (customKernelPatches.optimizeForCPUArch config.aviallon.general.cpuArch)
; ;
loader.grub.enable = cfg.useGrub; loader.grub.enable = cfg.useGrub;

View file

@ -3,28 +3,30 @@ with lib;
let let
cfg = config.aviallon.general; cfg = config.aviallon.general;
desktopCfg = config.aviallon.desktop; desktopCfg = config.aviallon.desktop;
buildUserKeyFile = "remote_builder/id_builder"; buildUserPubKeyFile = ./nix/id_builder.pub;
buildUserPubKey = readFile ./nix/id_builder.pub; buildUserKeyFile = ./nix/id_builder;
buildUserKey = readFile ./nix/id_builder;
getSpeed = cores: threads: cores + (threads - cores) / 2; getSpeed = cores: threads: cores + (threads - cores) / 2;
mkBuildMachine = { mkBuildMachine = {
hostName, hostName,
cores, cores,
threads ? (cores * 2), threads ? (cores * 2),
features ? [ ], features ? [ ],
x86ver ? 1 }: x86ver ? 1
}:
rec { rec {
inherit hostName; inherit hostName;
system = "x86_64-linux"; system = "x86_64-linux";
maxJobs = cores / 2; maxJobs = cores / 2;
sshUser = "builder"; sshUser = "builder";
sshKey = "/etc/${buildUserKeyFile}"; sshKey = toString buildUserKeyFile;
speedFactor = getSpeed cores threads; speedFactor = getSpeed cores threads;
supportedFeatures = [ "kvm" "benchmark" ] supportedFeatures = [ "kvm" "benchmark" ]
++ optional (speedFactor > 8) "big-parallel" ++ optional (speedFactor > 8) "big-parallel"
++ optional (x86ver >= 2) "gccarch-x86-64-v2" ++ optional (x86ver >= 2) "gccarch-x86-64-v2"
++ optional (x86ver >= 3) "gccarch-x86-64-v3" ++ optional (x86ver >= 3) "gccarch-x86-64-v3"
++ features
; ;
}; };
in in
@ -116,7 +118,6 @@ in
gcc.tune = cfg.cpuTune; gcc.tune = cfg.cpuTune;
}; };
environment.etc."${buildUserKeyFile}".text = buildUserKey;
nix.buildMachines = [ nix.buildMachines = [
{ {
hostName = "lesviallon.fr"; hostName = "lesviallon.fr";
@ -130,13 +131,14 @@ in
isSystemUser = true; isSystemUser = true;
group = "builder"; group = "builder";
hashedPassword = mkForce null; # Must not have a password! hashedPassword = mkForce null; # Must not have a password!
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keyFiles = [
buildUserPubKey buildUserKeyFile
]; ];
shell = pkgs.bashInteractive;
}; };
users.groups.builder = {}; users.groups.builder = {};
nix.trustedUsers = [ "builder" ]; nix.trustedUsers = [ "builder" ];
nix.distributedBuilds = mkDefault false; nix.distributedBuilds = mkDefault true;
}; };
} }

View file

@ -79,6 +79,8 @@ in
enableWideVine = true; enableWideVine = true;
}; };
opensshOptimized = super.opensshOptimized or super.openssh;
scribus = super.scribus.overrideAttrs (old: rec { scribus = super.scribus.overrideAttrs (old: rec {
version = "1.5.8"; version = "1.5.8";
sha256 = "sha256-R4Fuj89tBXiP8WqkSZ+X/yJDHHd6d4kUmwqItFHha3Q="; sha256 = "sha256-R4Fuj89tBXiP8WqkSZ+X/yJDHHd6d4kUmwqItFHha3Q=";