From f4dc4786bc97ffaa997bdae21ecf4e0cb1b11ed8 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 27 Mar 2024 10:42:25 -0400 Subject: [PATCH] wip --- .envrc | 4 ++- clusters/github-runner/flake-module.nix | 48 +++++++++++++++++++++++++ flake.nix | 5 +++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 clusters/github-runner/flake-module.nix diff --git a/.envrc b/.envrc index 8392d15..e8ff5cc 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,3 @@ -use flake \ No newline at end of file +watch_file \ + clusters/github-runner/flake-module.nix +use flake diff --git a/clusters/github-runner/flake-module.nix b/clusters/github-runner/flake-module.nix new file mode 100644 index 0000000..ac55851 --- /dev/null +++ b/clusters/github-runner/flake-module.nix @@ -0,0 +1,48 @@ +{ self, lib, flake-parts-lib, ... }: + +let + inherit (flake-parts-lib) + mkPerSystemOption; + inherit (lib) + types; +in +{ + options.distributed-github-runner = { + # TODO: Move to personal-repos? + tokenFile = lib.mkOption { + type = types.string; + description = "The file containing the GitHub runner token"; + }; + runner-user = lib.mkOption { + type = types.string; + description = "The user to run the GitHub runner as"; + default = "github-runner"; + }; + runner-packages = lib.mkOption { + type = types.listOf types.package; + description = "Packages to install on the GitHub runners"; + default = [ ]; + }; + # NOTE: At some point, we want to support organization repositories as well. + personal-repos = lib.mkOption { + type = types.attrsOf (types.attrsOf (types.submodule { + options = { + num = lib.mkOption { + type = types.int; + description = "The number of runners to register for this repository"; + default = 1; + }; + }; + })); + description = "List of personal repositories to register the runner for"; + default = { }; + }; + outputs = { + nixosModule = lib.mkOption { + type = types.deferredModule; + description = "The NixOS module to use for the GitHub runner"; + internal = true; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index b32aa4b..c7e3ea2 100644 --- a/flake.nix +++ b/flake.nix @@ -42,8 +42,13 @@ ./home ./nixos ./nix-darwin + ./clusters/github-runner/flake-module.nix ]; + distributed-github-runner = { + tokenFile = "/run/keys/github-runner-token.secret"; + }; + # Colmena deployment configuration # See https://github.com/juspay/colmena-flake colmena-flake.deployment =