refactor(ops/clbot): use escapeSystemdPath
This is definitely faster than doing a roundtrip via a build. Change-Id: I7a02b828462def735fdb241ce729143e90bc5c75 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13236 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
40c213b63d
commit
fc7f013066
1 changed files with 3 additions and 10 deletions
|
|
@ -1,9 +1,8 @@
|
|||
# Module that configures CLBot, our Gerrit->IRC info bridge.
|
||||
{ depot, config, lib, pkgs, ... }:
|
||||
{ depot, config, lib, utils, ... }:
|
||||
|
||||
let
|
||||
inherit (builtins) attrValues concatStringsSep mapAttrs readFile;
|
||||
inherit (pkgs) runCommand;
|
||||
inherit (builtins) attrValues concatStringsSep mapAttrs;
|
||||
|
||||
inherit (lib)
|
||||
listToAttrs
|
||||
|
|
@ -11,7 +10,6 @@ let
|
|||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
removeSuffix
|
||||
types;
|
||||
|
||||
description = "Bot to forward CL notifications";
|
||||
|
|
@ -21,13 +19,8 @@ let
|
|||
concatStringsSep " "
|
||||
(attrValues (mapAttrs (key: value: "-${key} \"${toString value}\"") flags));
|
||||
|
||||
# Escapes a unit name for use in systemd
|
||||
systemdEscape = name: removeSuffix "\n" (readFile (runCommand "unit-name" { } ''
|
||||
${pkgs.systemd}/bin/systemd-escape '${name}' >> $out
|
||||
''));
|
||||
|
||||
mkUnit = channel: channelFlags: {
|
||||
name = "clbot-${systemdEscape channel}";
|
||||
name = "clbot-${utils.escapeSystemdPath channel}";
|
||||
value = {
|
||||
description = "${description} to ${channel}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue