From cede676eb05e25b39fd3720dba83593c30b1d858 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 16:48:20 -0400 Subject: [PATCH] Setup distributed --- systems/darwin.nix | 19 +++++++++++++++++++ systems/github-runner.nix | 16 +++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/systems/darwin.nix b/systems/darwin.nix index 5935557..74ee6ca 100644 --- a/systems/darwin.nix +++ b/systems/darwin.nix @@ -8,6 +8,25 @@ ../nix-darwin/zsh-completion-fix.nix ]; + # Github runner CI + users = { + knownUsers = [ "github-runner" ]; + forceRecreate = true; + users.github-runner = { + uid = 1009; + description = "GitHub Runner"; + home = "/Users/github-runner"; + createHome = true; + shell = pkgs.bashInteractive; + # NOTE: Go to macOS Remote-Login settings and allow all users to ssh. + openssh.authorizedKeys.keys = [ + # github-runner VM's /etc/ssh/ssh_host_ed25519_key.pub + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUJvyuUnIs2q2TkJq29wqJ6HyOAeMmIK8PcH7xAlpVY root@github-runner" + ]; + }; + }; + nix.settings.trusted-users = [ "github-runner" ]; + nixpkgs.hostPlatform = "aarch64-darwin"; environment.systemPackages = with pkgs; [ diff --git a/systems/github-runner.nix b/systems/github-runner.nix index e3b6ae2..8cd3a7c 100644 --- a/systems/github-runner.nix +++ b/systems/github-runner.nix @@ -2,8 +2,9 @@ # - [x] Intial config # - [x] Colmena deploy, with keys from 1Password. # - [x] Github Runners -# - [ ] Distributed builder to host (macOS) +# - [x] Distributed builder to host (macOS) # - [x] Refactor, to allow multiple repos (then remove easy-github-runners.nix) +# - [ ] Refactor into own dir { flake, pkgs, lib, ... }: let @@ -29,6 +30,7 @@ let ]; url = "https://github.com/${user}/${repoName}"; }))); + hostIP = "10.37.129.2"; # Find out using `ifconfig` on host, looking for bridge101 in { imports = [ @@ -62,4 +64,16 @@ in services.github-runners = mkPersonalRunners "srid" { perpetuum.num = 2; }; + + # macOS remote builder + nix.distributedBuilds = true; + nix.buildMachines = [{ + hostName = hostIP; + systems = [ "aarch64-darwin" "x86_64-darwin" ]; + # supportedFeatures = [ "kvm" "benchmark" "big-parallel" ]; + maxJobs = 6; # 6 cores + protocol = "ssh-ng"; + sshUser = user; + sshKey = "/etc/ssh/ssh_host_ed25519_key"; + }]; }