From fc7f0130668bd013e20a6c9a135b6d93e12da067 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 10 Mar 2025 14:06:00 +0700 Subject: [PATCH] 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 Reviewed-by: sterni --- ops/modules/clbot.nix | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ops/modules/clbot.nix b/ops/modules/clbot.nix index 0a436a874..f671de26f 100644 --- a/ops/modules/clbot.nix +++ b/ops/modules/clbot.nix @@ -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" ];