about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/continuous-integration/github-runners.nix
blob: 66ace9580eca5760cea8607107e2ffb02535acf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ config
, pkgs
, lib
, ...
}@args:

with lib;

let
  cfg = config.services.github-runners;

in

{
  options.services.github-runners = mkOption {
    default = {};
    type = with types; attrsOf (submodule { options = import ./github-runner/options.nix (args // {
      # services.github-runners.${name}.name doesn't have a default; it falls back to ${name} below.
      includeNameDefault = false;
    }); });
    example = {
      runner1 = {
        enable = true;
        url = "https://github.com/owner/repo";
        name = "runner1";
        tokenFile = "/secrets/token1";
      };

      runner2 = {
        enable = true;
        url = "https://github.com/owner/repo";
        name = "runner2";
        tokenFile = "/secrets/token2";
      };
    };
    description = lib.mdDoc ''
      Multiple GitHub Runners.
    '';
  };

  config = {
    systemd.services = flip mapAttrs' cfg (n: v:
      let
        svcName = "github-runner-${n}";
      in
        nameValuePair svcName
        (import ./github-runner/service.nix (args // {
          inherit svcName;
          cfg = v // {
            name = if v.name != null then v.name else n;
          };
          systemdDir = "github-runner/${n}";
        }))
    );
  };

  meta.maintainers = with maintainers; [ veehaitch newam ];
}