aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/senpai/default.nix
blob: 51fc041df94e8108a8bb9486737c6325d4eb65e9 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Senpai TUI IRC client module
{
  config,
  lib,
  pkgs,
  ...
}:
{
  imports = [ ./assertions.nix ];

  options.communication.senpai = {
    enable = lib.mkEnableOption "Senpai TUI IRC client";

    package = lib.mkOption {
      type = lib.types.package;
      default = pkgs.senpai;
      description = "The senpai package to use.";
    };

    server = {
      address = lib.mkOption {
        type = lib.types.str;
        description = "IRC server address (host[:port]). Supports irc://, ircs://, irc+insecure:// URLs.";
      };
    };

    identity = {
      nickname = lib.mkOption {
        type = lib.types.str;
        description = "Your IRC nickname (no spaces or colons).";
      };

      passwordGopassSecret = lib.mkOption {
        type = lib.types.nullOr lib.types.str;
        default = null;
        description = "Gopass secret path for SASL password (e.g. irc/user@server). Constructs password-cmd automatically.";
      };
    };
  };

  config = lib.mkIf config.communication.senpai.enable {
    programs.senpai = {
      enable = true;
      package = config.communication.senpai.package;
      config = {
        address = config.communication.senpai.server.address;
        nickname = config.communication.senpai.identity.nickname;
        password-cmd = lib.mkIf (config.communication.senpai.identity.passwordGopassSecret != null) [
          (lib.getExe config.security.gopass.package)
          "show"
          "-o"
          config.communication.senpai.identity.passwordGopassSecret
        ];
      };
    };
  };
}