From f761ede7ff522c1d962c9ff093596598cf603811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 19 Apr 2025 16:48:45 +0200 Subject: [PATCH] fix: eval error --- modules/remote_builders.nix | 65 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/modules/remote_builders.nix b/modules/remote_builders.nix index 2cb7e2b..82f03d3 100644 --- a/modules/remote_builders.nix +++ b/modules/remote_builders.nix @@ -11,48 +11,46 @@ mkEnableOption mkIf mapAttrsToList - attrNames - map concatLines mkOption types ; cfg = config.our.buildMachines; - others = filterAttrs (n: _v: n != config.networking.hostName) self.nixosConfigurations; + builders = filterAttrs (_n: v: v.config.our.buildMachines.enable) self.nixosConfigurations; + others = filterAttrs (n: _v: n != config.networking.hostName) builders; mkBuilder = hostName: attrs: let config' = attrs.config; cfg' = config'.our.buildMachines; pkgs' = attrs.pkgs; - in - mkIf cfg'.enable { - # NOTE: https://github.com/NixOS/nix/issues/3177 - hostName = - if hostName == config.networking.hostName - then "local?root=/nix/store" - else hostName; - sshUser = - if hostName == config.networking.hostName - then null - else "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; - # Nix custom ssh-variant that avoids lots of "trusted-users" settings pain - protocol = - if hostName == config.networking.hostName - then null - else "ssh-ng"; - # default is 1 but may keep the builder idle in between builds - maxJobs = 3; - speedFactor = 1; - supportedFeatures = cfg'.supportedFeatures; - mandatoryFeatures = []; - }; + in { + # NOTE: https://github.com/NixOS/nix/issues/3177 + hostName = + if hostName == config.networking.hostName + then "local?root=/nix/store" + else hostName; + sshUser = + if hostName == config.networking.hostName + then null + else "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; + # Nix custom ssh-variant that avoids lots of "trusted-users" settings pain + protocol = + if hostName == config.networking.hostName + then null + else "ssh-ng"; + # default is 1 but may keep the builder idle in between builds + maxJobs = 3; + speedFactor = 1; + supportedFeatures = cfg'.supportedFeatures; + mandatoryFeatures = []; + }; - buildMachines = mapAttrsToList mkBuilder self.nixosConfigurations; + buildMachines = mapAttrsToList mkBuilder builders; remotebuildKeys = mapAttrsToList ( @@ -60,12 +58,11 @@ ) others; - mkMatch = host: '' - Match User remotebuild Host ${host} + mkMatch = hostName: _v: '' + Match User remotebuild Host ${hostName} IdentityFile ${config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519".path} ''; - othersName = attrNames others; - sshConfig = concatLines (map mkMatch othersName); + sshConfig = concatLines (mapAttrsToList mkMatch others); in { options.our.buildMachines = { enable = mkEnableOption "Use this machine as a remoteBuilder for others and vice versa.";