Set runner name to attr name for github-runners.${name}

This commit is contained in:
Tom McLaughlin 2022-10-14 05:31:50 -06:00
parent fc8fdb03a0
commit 2c099d1a14
3 changed files with 13 additions and 7 deletions

View File

@ -11,7 +11,7 @@ let
in in
{ {
options.services.github-runner = import ./github-runner/options.nix args; options.services.github-runner = import ./github-runner/options.nix (args // { includeNameDefault = true; });
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.github-runners.${cfg.name} = cfg; services.github-runners.${cfg.name} = cfg;

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: { config
, lib
, pkgs
, includeNameDefault
, ...
}:
with lib; with lib;
@ -59,6 +64,7 @@ with lib;
Changing this option triggers a new runner registration. Changing this option triggers a new runner registration.
''; '';
example = "nixos"; example = "nixos";
} // lib.optionalAttrs includeNameDefault {
default = config.networking.hostName; default = config.networking.hostName;
defaultText = literalExpression "config.networking.hostName"; defaultText = literalExpression "config.networking.hostName";
}; };

View File

@ -14,7 +14,7 @@ in
{ {
options.services.github-runners = mkOption { options.services.github-runners = mkOption {
default = {}; default = {};
type = with types; attrsOf (submodule { options = import ./github-runner/options.nix args; }); type = with types; attrsOf (submodule { options = import ./github-runner/options.nix (args // { includeNameDefault = false; }); });
example = { example = {
runner1 = { runner1 = {
enable = true; enable = true;
@ -36,15 +36,15 @@ in
}; };
config = { config = {
systemd.services = flip mapAttrs' cfg (n: v: systemd.services = flip mapAttrs' cfg (name: v:
let let
svcName = "github-runner-${n}"; svcName = "github-runner-${name}";
in in
nameValuePair svcName nameValuePair svcName
(import ./github-runner/service.nix (args // { (import ./github-runner/service.nix (args // {
inherit svcName; inherit svcName;
cfg = v; cfg = v // { inherit name; };
systemdDir = "github-runner/${n}"; systemdDir = "github-runner/${name}";
})) }))
); );
}; };