summaryrefslogtreecommitdiff
path: root/custom/uucp-notifyclient.nix
blob: 5b74c1e01d78b37e244cce8c543b0633bf12bf84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.uucp.notify-client;

  nodeConfig = {
    options = {
      allowedUsers = mkOption {
        type = with types; uniq (listOf str);
        default = services.notify-users.allowedUsers;
      };
    };
  };
in {
  options = {
    services.uucp.notify-client = {
      remoteNodes = mkOption {
        type = with types; attrsOf (submodule nodeConfig);
        default = [];
        description = ''
          Servers to receive notifications from
        '';
      };
    };
  };

  imports = [ ./notify-users.nix ];

  config = mkIf (cfg.remoteNodes != {}) {
    services.notify-users = concatMap ({ allowedUsers }: allowedUsers) cfg.remoteNodes;

    services.uucp.remoteNodes = mapAttrs (name: { allowedUsers, ... }: { commands = map (user: "notify-${user}") allowedUsers; }) cfg.remoteNodes;
    services.uucp.commandPath = [ config.security.wrapperDir ];
  };
}