From 67de7d105ea6b400d66628b703c69fa171b9f08a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 23 Mar 2023 14:13:26 +0000 Subject: [PATCH] nixos/woodpecker-agents: per-agent 'enable' option --- nixos/doc/manual/release-notes/rl-2305.section.md | 2 +- .../continuous-integration/woodpecker/agents.nix | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index ee0db1001b06..b88c8dfb0c87 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -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). diff --git a/nixos/modules/services/continuous-integration/woodpecker/agents.nix b/nixos/modules/services/continuous-integration/woodpecker/agents.nix index ac6ec45c0ba7..2dd6e39bdd94 100644 --- a/nixos/modules/services/continuous-integration/woodpecker/agents.nix +++ b/nixos/modules/services/continuous-integration/woodpecker/agents.nix @@ -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; }; }