From 32ea399d8938ff45b78d7e104cf04894161bcd1a Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 18 Nov 2026 12:50:45 -0500 Subject: [PATCH] github runners --- flake.nix | 1 + hosts/hl-fws1/services/default.nix | 2 +- hosts/hl-fws1/services/github-runners.nix | 78 +++++++++++++++++++++++ secrets.nix | 2 + secrets/github-runner-token-fws1.age | 7 ++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 hosts/hl-fws1/services/github-runners.nix create mode 100644 secrets/github-runner-token-fws1.age diff --git a/flake.nix b/flake.nix index 4f21738..2d7804f 100644 --- a/flake.nix +++ b/flake.nix @@ -198,6 +198,7 @@ nbot-goose = ./secrets/nbot-goose.age; nbot-cluster = ./secrets/nbot-cluster.age; nbot-cluster-hl-fws1 = ./secrets/nbot-cluster-hl-fws1.age; + github-runner-token-fws1 = ./secrets/github-runner-token-fws1.age; }; inherit hyprlauncher diff --git a/hosts/hl-fws1/services/default.nix b/hosts/hl-fws1/services/default.nix index fbe9ff7..b8dbd93 100644 --- a/hosts/hl-fws1/services/default.nix +++ b/hosts/hl-fws1/services/default.nix @@ -1,6 +1,6 @@ { ... }: { - imports = [ ./nbot.nix ]; + imports = [ ./nbot.nix ./github-runners.nix ]; services.pipewire = { extraConfig.pipewire-pulse."10-raop-discover" = { diff --git a/hosts/hl-fws1/services/github-runners.nix b/hosts/hl-fws1/services/github-runners.nix new file mode 100644 index 0000000..c0ca2ac --- /dev/null +++ b/hosts/hl-fws1/services/github-runners.nix @@ -0,0 +1,78 @@ +{ config, lib, skyg-secrets, ... }: +let + concurrency = 4; + runnerNames = map (i: "runner-${toString i}") (lib.range 1 concurrency); + stateVersion = config.system.stateVersion; + cache = "/var/cache/github-runners/go"; + credentials = "/run/github-runner-registration"; + + # The same numeric identity owns the bind-mounted caches on the host and in every container. + runnerUser = { + users.github-runner = { + uid = 915; + isSystemUser = true; + group = "github-runner"; + }; + groups.github-runner.gid = 915; + }; +in +{ + age.secrets.github-runner-token-fws1 = { + file = skyg-secrets.github-runner-token-fws1; + path = "${credentials}/token"; + # The containers mount this directory and must see token rotations. + symlink = false; + mode = "0400"; + }; + + users = runnerUser; + systemd.tmpfiles.rules = [ + "d ${credentials} 0700 root root -" + "d ${cache} 0755 root root -" + "d ${cache}/build 0700 github-runner github-runner -" + "d ${cache}/mod 0700 github-runner github-runner -" + ]; + + systemd.services = lib.genAttrs (map (name: "container@${name}") runnerNames) (_: { + serviceConfig = { + MemoryLow = "4G"; + MemoryMax = "8G"; + CPUQuota = "200%"; + }; + }); + + containers = lib.genAttrs runnerNames (name: { + autoStart = true; + bindMounts = { + "${credentials}".isReadOnly = true; + "/var/cache/go" = { + hostPath = cache; + isReadOnly = false; + }; + }; + + config = { pkgs, ... }: { + system.stateVersion = stateVersion; + users = runnerUser; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + services.github-runners.${name} = { + enable = true; + inherit name; + replace = true; + url = "https://github.com/SkyG-Org"; + tokenFile = "${credentials}/token"; + user = "github-runner"; + group = "github-runner"; + extraLabels = [ "fws1" "nixos" "go" ]; + extraPackages = [ pkgs.go ]; + extraEnvironment = { + NIX_REMOTE = "daemon"; + GOCACHE = "/var/cache/go/build"; + GOMODCACHE = "/var/cache/go/mod"; + }; + serviceOverrides.ReadWritePaths = [ "/var/cache/go" ]; + }; + }; + }); +} diff --git a/secrets.nix b/secrets.nix index a58f687..8471a56 100644 --- a/secrets.nix +++ b/secrets.nix @@ -35,6 +35,8 @@ in "secrets/nbot-cluster.age".publicKeys = [ ari fwdesk ]; "secrets/nbot-cluster-hl-fws1.age".publicKeys = [ ari fws1 ]; + "secrets/github-runner-token-fws1.age".publicKeys = [ ari fws1 ]; + # Buzz stack env (minipc1) "secrets/buzz-env.age".publicKeys = [ ari minipc1 ]; diff --git a/secrets/github-runner-token-fws1.age b/secrets/github-runner-token-fws1.age new file mode 100644 index 0000000..9f7a18e --- /dev/null +++ b/secrets/github-runner-token-fws1.age @@ -0,0 +1,7 @@ +age-encryption.org/v1 +-> ssh-ed25519 CIR0mA L83QWLnE5GVGD0exCETcRL+nDKb42ItcG3N2cpPaGgs +9PiiapcU18WKrwvAqgiZNjuYQEo61sykwVZtvJ8JS+8 +-> ssh-ed25519 KFBpLw QTpLVyI872MepWcJyeFQBR6RB+xVy9lK28kshgl+IiQ +dFKmJDffaC2Ig8fEwb9kJ0tdedK24J/CnjK40Yor5HQ +--- WeEsbTKGDvopQNxQpXMCTL4hhqmhljQb7bv5c4oaHXw +Bžþoú#” µ×gÆE+‹O…¹^ ÙÅ,%LO÷¦uàYJÃh‚ø‚ç\É"¹ÑçÞËŠí¥ã \ No newline at end of file