From 9559ef56e3935618d63bc7b96136ec06db7e9bec Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Mon, 13 May 2024 17:54:34 +0200 Subject: feat(fun/clbot,ops/machines/whitby): filter tvix-dev clbot In #tvix-dev, we want to display only CLs that relate to tvix and related projects. So use a pretty dumb allow-list for which CLs to display in that channel. Change-Id: I3ef50b64e3d7fbc27a6690be6a10f1b55c04cd6e Reviewed-on: https://cl.tvl.fyi/c/depot/+/11658 Reviewed-by: flokli Reviewed-by: lukegb Tested-by: BuildkiteCI --- ops/machines/whitby/default.nix | 7 ++++++- ops/modules/clbot.nix | 11 ++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'ops') diff --git a/ops/machines/whitby/default.nix b/ops/machines/whitby/default.nix index 41391c8c0b87..4c2fd0f2f533 100644 --- a/ops/machines/whitby/default.nix +++ b/ops/machines/whitby/default.nix @@ -347,7 +347,12 @@ in # Start the Gerrit->IRC bot services.depot.clbot = { enable = true; - channels = [ "#tvix-dev" "#tvl" ]; + channels = { + "#tvl" = { }; + "#tvix-dev" = { + only_display = "tvix,nix-compat,third_party,third-party,3p"; + }; + }; # See //fun/clbot for details. flags = { diff --git a/ops/modules/clbot.nix b/ops/modules/clbot.nix index bdddff6c810b..0a436a8749d0 100644 --- a/ops/modules/clbot.nix +++ b/ops/modules/clbot.nix @@ -7,6 +7,7 @@ let inherit (lib) listToAttrs + mapAttrsToList mkEnableOption mkIf mkOption @@ -25,13 +26,13 @@ let ${pkgs.systemd}/bin/systemd-escape '${name}' >> $out '')); - mkUnit = flags: channel: { + mkUnit = channel: channelFlags: { name = "clbot-${systemdEscape channel}"; value = { description = "${description} to ${channel}"; wantedBy = [ "multi-user.target" ]; - script = "${depot.fun.clbot}/bin/clbot ${mkFlags (cfg.flags // { + script = "${depot.fun.clbot}/bin/clbot ${mkFlags (cfg.flags // channelFlags // { irc_channel = channel; })} -alsologtostderr"; @@ -53,8 +54,8 @@ in }; channels = mkOption { - type = with types; listOf str; - description = "Channels in which to post (generates one unit per channel)"; + type = with types; attrsOf (attrsOf str); + description = "Channels in which to post (generates one unit per channel); nested attrs are used as extra flags to the service, which override the attrs in `flags`"; }; secretsFile = mkOption { @@ -77,6 +78,6 @@ in }; }; - systemd.services = listToAttrs (map (mkUnit cfg.flags) cfg.channels); + systemd.services = listToAttrs (mapAttrsToList mkUnit cfg.channels); }; } -- cgit 1.4.1