aboutsummaryrefslogtreecommitdiffstats
path: root/modules/communication/senpai/default.nix
blob: 274e4d7753fe0d71531de239db974cf0b006768e (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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
        ];
      };
    };

    xdg.desktopEntries."senpai" = {
      name = "Senpai";
      exec = "${lib.getExe config.terminal.kitty.package} --class senpai -e ${lib.getExe config.communication.senpai.package}";
      icon = "senpai";
      categories = [
        "Network"
        "Chat"
      ];
      comment = "Senpai TUI IRC Client";
      terminal = false;
      type = "Application";
    };

    xdg.mimeApps.defaultApplications = {
      "x-scheme-handler/irc" = "senpai.desktop";
      "x-scheme-handler/ircs" = "senpai.desktop";
    };
  };
}