style: format everything

This commit is contained in:
Moritz Böhme 2025-04-13 17:58:17 +02:00
parent f4c27362c4
commit 4da8981990
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
120 changed files with 1550 additions and 1655 deletions

View file

@ -4,10 +4,9 @@
pkgs,
self,
...
}:
let
inherit (lib)
}: let
inherit
(lib)
filterAttrs
mkEnableOption
mkIf
@ -20,48 +19,49 @@ let
;
cfg = config.our.buildMachines;
others = filterAttrs (n: v: n != config.networking.hostName) self.nixosConfigurations;
others = filterAttrs (n: _v: n != config.networking.hostName) self.nixosConfigurations;
max = a: b: if a > b then a else b;
max = a: b:
if a > b
then a
else b;
mkBuilder =
hostName: attrs:
let
config' = attrs.config;
cfg' = config'.our.buildMachines;
pkgs' = attrs.pkgs;
in
mkBuilder = hostName: attrs: let
config' = attrs.config;
cfg' = config'.our.buildMachines;
pkgs' = attrs.pkgs;
in
mkIf cfg'.enable {
hostName = hostName;
sshUser = "remotebuild";
# CPU architecture of the builder, and the operating system it runs.
# If your builder supports multiple architectures
# (e.g. search for "binfmt" for emulation),
systems = [ pkgs'.system ] ++ config'.boot.binfmt.emulatedSystems;
systems = [pkgs'.system] ++ config'.boot.binfmt.emulatedSystems;
# Nix custom ssh-variant that avoids lots of "trusted-users" settings pain
protocol = "ssh-ng";
# default is 1 but may keep the builder idle in between builds
maxJobs = 3;
speedFactor = max (cfg'.speedFactor - cfg.speedFactor + 1) 1;
supportedFeatures = cfg'.supportedFeatures;
mandatoryFeatures = [ ];
mandatoryFeatures = [];
};
buildMachines = mapAttrsToList mkBuilder others;
remotebuildKeys = mapAttrsToList (
_name: attrs: attrs.config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519.pub".value
) others;
remotebuildKeys =
mapAttrsToList (
_name: attrs: attrs.config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519.pub".value
)
others;
mkMatch = host:
''
Match User remotebuild Host ${host}
IdentityFile ${config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519".path}
'';
mkMatch = host: ''
Match User remotebuild Host ${host}
IdentityFile ${config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519".path}
'';
othersName = attrNames others;
sshConfig = concatLines (map mkMatch othersName);
in
{
in {
options.our.buildMachines = {
enable = mkEnableOption "Use this machine as a remoteBuilder for others and vice versa.";
supportedFeatures = mkOption {
@ -73,7 +73,7 @@ in
"kvm"
]
);
default = [ ];
default = [];
description = ''
kvm | Everything which builds inside a vm, like NixOS tests
nixos-test | Machine can run NixOS tests
@ -96,10 +96,10 @@ in
openssh.authorizedKeys.keys = remotebuildKeys;
};
users.groups.remotebuild = { };
users.groups.remotebuild = {};
clan.core.vars.generators.remotebuild = {
files."ssh.id_ed25519" = { };
files."ssh.id_ed25519" = {};
files."ssh.id_ed25519.pub".secret = false;
runtimeInputs = [
pkgs.coreutils
@ -119,7 +119,7 @@ in
# optional, useful when the builder has a faster internet connection than yours
settings = {
builders-use-substitutes = true;
trusted-users = [ "remotebuild" ];
trusted-users = ["remotebuild"];
};
};
};