Skip to content

Commit

Permalink
fix(builders|ops): prevent failure with missing host attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
montchr committed Sep 29, 2024
1 parent b0b1992 commit 7745e68
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions nixos/profiles/remote-builders/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@

nix.distributedBuilds = true;

lib.dotfield.mkBuildMachine =
machine:
lib.dotfield.mkBuildMachine = config.lib.dotfield.mkBuildMachineFor config.networking.hostName;
lib.dotfield.mkBuildMachineFor =
localHostName: builderHostName:
let
inherit (config.networking) hostName;
inherit (ops.hosts.${hostName}.hardware) vcpus;

hw = ops.hosts.${machine}.hardware;
localVcpus = ops.hosts.${localHostName}.hardware.vcpus or 1;
builder = ops.hosts.${builderHostName}.hardware or { };
builderVcpus = builder.vcpus or 1;
in
{
inherit (hw) system;
hostName = machine;
speedFactor = builtins.ceil vcpus / hw.vcpus;
inherit (builder) system;
hostName = builderHostName;

# TODO: should be reversed, right?
# speedFactor = builtins.ceil builderVcpus / localVcpus;
speedFactor = builtins.ceil localVcpus / builderVcpus;

protocol = "ssh-ng";
# maxJobs = 2;
supportedFeatures = [
Expand Down

0 comments on commit 7745e68

Please sign in to comment.