From a58b62baa6186c961017662ffb053e17dfbb95ba Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 8 Jan 2025 19:29:33 +0000 Subject: [PATCH] fix distributed setup local --- flake.lock | 8 ++--- .../distributed_builds/local-machine.nix | 29 +++++++++++++++++++ hosts/semita/default.nix | 2 ++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index b638e66..a7f55b9 100644 --- a/flake.lock +++ b/flake.lock @@ -487,11 +487,11 @@ }, "nix-secrets": { "locked": { - "lastModified": 1736337009, - "narHash": "sha256-5seeOYCOJrvhbKIj64bAzeSJN80hdVp08ufArlBf+qg=", + "lastModified": 1736339437, + "narHash": "sha256-Em8E6Ml2whMU1IoEB3OI3eKhjSu2J/xbXdlIt+8x61U=", "ref": "refs/heads/master", - "rev": "bd63772717581b787f1f2aaac3fb909eaae2c2b7", - "revCount": 193, + "rev": "7c6042a975808186934e012ad32ae0e03ab60bff", + "revCount": 194, "type": "git", "url": "ssh://git@git.bitlab21.com/sam/nix-secrets.git" }, diff --git a/hosts/common/optional/distributed_builds/local-machine.nix b/hosts/common/optional/distributed_builds/local-machine.nix index 6849490..bb8d775 100644 --- a/hosts/common/optional/distributed_builds/local-machine.nix +++ b/hosts/common/optional/distributed_builds/local-machine.nix @@ -1,4 +1,33 @@ +{ pkgs, configVars, ... }: +let + remoteMachineIp = configVars.networking.addresses.remote-builder.ip; +in { + nix.distributedBuilds = true; + nix.settings.builders-use-substitutes = true; + nix.settings.max-jobs = 0; + nix.settings.trusted-substituters = ["ssh://${remoteMachineIp}"]; + nix.settings.substituters = ["ssh://${remoteMachineIp}"]; + + nix.buildMachines = [ + { + hostName = remoteMachineIp; + sshUser = "remotebuild"; + speedFactor = 1; + maxJobs = 10; + sshKey = "/root/.ssh/remotebuild"; + system = pkgs.stdenv.hostPlatform.system; + supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + } + ]; + + # TODO: set known host here when have static ip on main server + # programs.ssh.knownHosts = { + # "merlin" = { + # publicKey = "server pubkey"; + # }; + # }; + sops.secrets = { "ssh_keys/root/remotebuild" = { path = "/root/.ssh/remotebuild"; diff --git a/hosts/semita/default.nix b/hosts/semita/default.nix index 5031bb9..40db136 100644 --- a/hosts/semita/default.nix +++ b/hosts/semita/default.nix @@ -59,6 +59,8 @@ in { ../common/optional/restic-backup.nix ../common/optional/nixos-containers/backup-server.nix + + ../common/optional/distributed_builds/local-machine.nix ]; fileSystems."/media/main-ssd" = {