diff options
author | Vincent Ambo <mail@tazj.in> | 2020-06-30T23·15+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-06-30T23·39+0000 |
commit | feb3f1a374d199aa4c7773b7ade4af2faa7b7530 (patch) | |
tree | e1cb89e408084d9bb941a44df3992b06312328ba /ops/nixos | |
parent | 7839b7b7a3a0433cc6eca411f96e8032e45d9f0d (diff) |
feat(nixos/clbot): Add a module for running clbot r/1142
Change-Id: I9c10906441c3222b74bcc820a67f11d96462fcfa Reviewed-on: https://cl.tvl.fyi/c/depot/+/821 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: BuildkiteCI
Diffstat (limited to 'ops/nixos')
-rw-r--r-- | ops/nixos/clbot.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ops/nixos/clbot.nix b/ops/nixos/clbot.nix new file mode 100644 index 000000000000..adcbebd57fd0 --- /dev/null +++ b/ops/nixos/clbot.nix @@ -0,0 +1,52 @@ +# Module that configures CLBot, our Gerrit->IRC info bridge. +{ config, lib, pkgs, ... }: + +let + inherit (builtins) concatStringsSep attrValues mapAttrs; + inherit (lib) + mkEnableOption + mkIf + mkOption + types; + + description = "CLBot forwards Gerrit notifications to IRC"; + cfg = config.services.depot.clbot; + + mkFlags = flags: + concatStringsSep " " + (attrValues (mapAttrs (key: value: "-${key} \"${toString value}\"") flags)); +in { + options.services.depot.clbot = { + enable = mkEnableOption description; + flags = mkOption { + type = types.attrsOf types.str; + description = "Key value pairs for command line flags"; + }; + }; + + config = mkIf cfg.enable { + # This does not use DynamicUser because we need to make some files + # (notably the SSH private key) readable by this user outside of + # the module. + users = { + groups.clbot = {}; + + users.clbot = { + group = "clbot"; + isNormalUser = false; + }; + }; + + systemd.services.clbot = { + inherit description; + script = "${config.depot.fun.clbot}/bin/clbot ${mkFlags cfg.flags} -alsologtostderr"; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + User = "clbot"; + EnvironmentFile = "/etc/secrets/clbot"; + Restart = "always"; + }; + }; + }; +} |