mirror of
https://github.com/srid/nixos-config.git
synced 2026-04-05 17:55:30 +08:00
clusters/github-runner: init
This commit is contained in:
parent
cede676eb0
commit
96672a0bda
5 changed files with 86 additions and 74 deletions
22
clusters/github-runner/darwin-module.nix
Normal file
22
clusters/github-runner/darwin-module.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
# 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" ];
|
||||
}
|
||||
54
clusters/github-runner/nixos-module.nix
Normal file
54
clusters/github-runner/nixos-module.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{ flake, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (flake) inputs;
|
||||
inherit (inputs) self;
|
||||
user = "github-runner";
|
||||
group = "github-runner";
|
||||
tokenFile = "/run/keys/github-runner-token.secret"; # See colmena keys in top-level flake.nix
|
||||
# Convenient function to create multiple runners per single personal repo.
|
||||
mkPersonalRunners = user:
|
||||
lib.concatMapAttrs (repoName: meta:
|
||||
lib.listToAttrs (lib.flip builtins.map (lib.range 1 meta.num) (idx:
|
||||
let
|
||||
name = "${repoName}-${builtins.toString idx}";
|
||||
in
|
||||
lib.nameValuePair name {
|
||||
inherit user group tokenFile name;
|
||||
enable = true;
|
||||
replace = true;
|
||||
extraPackages = with pkgs; [
|
||||
coreutils
|
||||
nixci
|
||||
];
|
||||
url = "https://github.com/${user}/${repoName}";
|
||||
})));
|
||||
hostIP = "10.37.129.2"; # Find out using `ifconfig` on host, looking for bridge101
|
||||
in
|
||||
{
|
||||
|
||||
# User
|
||||
users.users.${user} = {
|
||||
inherit group;
|
||||
isSystemUser = true;
|
||||
};
|
||||
users.groups.${group} = { };
|
||||
nix.settings.trusted-users = [ user ];
|
||||
|
||||
# Runners
|
||||
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";
|
||||
}];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue