diff options
author | Vincent Ambo <mail@tazj.in> | 2021-04-11T20·50+0200 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-04-11T22·18+0000 |
commit | 90281c4eac4cd25045ed80c5f8f27c74898a02b3 (patch) | |
tree | 804425642af16b9e299d469ad6e21c6a23a400e9 /ops/nixos/clbot.nix | |
parent | 7deabb8c8d6f4c7e58e2b16548b8a1895795963b (diff) |
refactor(ops): Split //ops/nixos into different locations r/2482
Splits //ops/nixos into: * //ops/nixos.nix - utility functions for building systems * //ops/machines - shared machine definitions (read by readTree) * //ops/modules - shared NixOS modules (skipped by readTree) This simplifies working with the configuration fixpoint in whitby, and is overall a bit more in line with how NixOS systems in user folders currently work. Change-Id: I1322ec5cc76c0207c099c05d44828a3df0b3ffc1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2931 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'ops/nixos/clbot.nix')
-rw-r--r-- | ops/nixos/clbot.nix | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/ops/nixos/clbot.nix b/ops/nixos/clbot.nix deleted file mode 100644 index ad33e25a4d54..000000000000 --- a/ops/nixos/clbot.nix +++ /dev/null @@ -1,75 +0,0 @@ -# Module that configures CLBot, our Gerrit->IRC info bridge. -{ depot, config, lib, pkgs, ... }: - -let - inherit (builtins) attrValues concatStringsSep mapAttrs readFile; - inherit (pkgs) runCommandNoCC; - - inherit (lib) - listToAttrs - mkEnableOption - mkIf - mkOption - removeSuffix - types; - - description = "Bot to forward CL notifications"; - cfg = config.services.depot.clbot; - - mkFlags = flags: - concatStringsSep " " - (attrValues (mapAttrs (key: value: "-${key} \"${toString value}\"") flags)); - - # Escapes a unit name for use in systemd - systemdEscape = name: removeSuffix "\n" (readFile (runCommandNoCC "unit-name" {} '' - ${pkgs.systemd}/bin/systemd-escape '${name}' >> $out - '')); - - mkUnit = flags: channel: { - name = "clbot-${systemdEscape channel}"; - value = { - description = "${description} to ${channel}"; - wantedBy = [ "multi-user.target" ]; - - script = "${depot.fun.clbot}/bin/clbot ${mkFlags (cfg.flags // { - irc_channel = channel; - })} -alsologtostderr"; - - serviceConfig = { - User = "clbot"; - EnvironmentFile = "/etc/secrets/clbot"; - Restart = "always"; - }; - }; - }; -in { - options.services.depot.clbot = { - enable = mkEnableOption description; - - flags = mkOption { - type = types.attrsOf types.str; - description = "Key value pairs for command line flags"; - }; - - channels = mkOption { - type = with types; listOf str; - description = "Channels in which to post (generates one unit per channel)"; - }; - }; - - 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 = listToAttrs (map (mkUnit cfg.flags) cfg.channels); - }; -} |