* users/grfn/system/home/yeren: remove obsolete awscli2 overrides * ops: make new isSystemUser || isNormalUser assertion happy * users/grfn/system/system/mugwump: make buildkite agents system users * users/tazjin/nixos/camden: set isSystemUser = true for git * users/tazjin/emacs: Remove missing & broken packages * third_party/openldap: remove, as the argon2 module is now enabled upstream * third_party/gerrit_plugins: Pinned new unstable hashes * third_party/nix, third_party/grpc: Disabled CI as these are broken * third_party/overlays/emacs: Bumped version to stay in sync with channel * third_party/buzz: Update LIBCLANG_PATH to reference libclang.lib, since libclang's default output no longer contains libclang.so * users/grfn/system/home: Install julia-stable instead of julia (which aliases to julia-lts), as the latter depends on an insecure version of libgit Change-Id: Iff33b0ecb0ef07a82d1de35e23c40d2f4bf0f8ed Reviewed-on: https://cl.tvl.fyi/c/depot/+/3001 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
		
			
				
	
	
		
			75 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
# 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";
 | 
						|
        isSystemUser = true;
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
    systemd.services = listToAttrs (map (mkUnit cfg.flags) cfg.channels);
 | 
						|
  };
 | 
						|
}
 |