nixos/woodpecker-agents: per-agent 'enable' option

This commit is contained in:
Bruno BELANYI 2023-03-23 14:13:26 +00:00
parent cd116db45e
commit 67de7d105e
2 changed files with 10 additions and 5 deletions

View file

@ -71,7 +71,7 @@ In addition to numerous new and upgraded packages, this release has the followin
- [nimdow](https://github.com/avahe-kellenberger/nimdow), a window manager written in Nim, inspired by dwm.
- [woodpecker-agents](https://woodpecker-ci.org/), a simple CI engine with great extensibility. Available as [services.woodpecker-agents](#opt-services.woodpecker-agents.enable).
- [woodpecker-agents](https://woodpecker-ci.org/), a simple CI engine with great extensibility. Available as [services.woodpecker-agents](#opt-services.woodpecker-agents.agents._name_.enable).
- [woodpecker-server](https://woodpecker-ci.org/), a simple CI engine with great extensibility. Available as [services.woodpecker-server](#opt-services.woodpecker-server.enable).

View file

@ -9,6 +9,8 @@ let
agentModule = lib.types.submodule {
options = {
enable = lib.mkEnableOption (lib.mdDoc "this Woodpecker-Agent. Agents execute tasks generated by a Server, every install will need one server and at least one agent");
package = lib.mkPackageOptionMD pkgs "woodpecker-agent" { };
environment = lib.mkOption {
@ -101,8 +103,6 @@ in
options = {
services.woodpecker-agents = {
enable = lib.mkEnableOption (lib.mdDoc "the Woodpecker-Agent, Agents execute tasks generated by a Server, every install will need one server and at least one agent");
agents = lib.mkOption {
default = { };
type = lib.types.attrsOf agentModule;
@ -133,7 +133,12 @@ in
};
};
config = lib.mkIf cfg.enable {
systemd.services = lib.mapAttrs' mkAgentService cfg.agents;
config = {
systemd.services =
let
mkServices = lib.mapAttrs' mkAgentService;
enabledAgents = lib.filterAttrs (_: agent: agent.enable) cfg.agents;
in
mkServices enabledAgents;
};
}