fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.0 KiB81 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.services.pantalaimon;
7
8  iniFmt = pkgs.formats.ini { };
9in {
10  meta.maintainers = [ maintainers.jojosch ];
11
12  options = {
13    services.pantalaimon = {
14      enable = mkEnableOption
15        "Pantalaimon, an E2EE aware proxy daemon for matrix clients";
16
17      package = mkOption {
18        type = types.package;
19        default = pkgs.pantalaimon;
20        defaultText = literalExpression "pkgs.pantalaimon";
21        description =
22          "Package providing the {command}`pantalaimon` executable to use.";
23      };
24
25      settings = mkOption {
26        type = iniFmt.type;
27        default = { };
28        defaultText = literalExpression "{ }";
29        example = literalExpression ''
30          {
31            Default = {
32              LogLevel = "Debug";
33              SSL = true;
34            };
35            local-matrix = {
36              Homeserver = "https://matrix.org";
37              ListenAddress = "127.0.0.1";
38              ListenPort = 8008;
39            };
40          }
41        '';
42        description = ''
43          Configuration written to
44          {file}`$XDG_CONFIG_HOME/pantalaimon/pantalaimon.conf`.
45
46          See <https://github.com/matrix-org/pantalaimon/blob/master/docs/manpantalaimon.5.md> or
47          {manpage}`pantalaimon(5)`
48          for options.
49        '';
50      };
51    };
52  };
53
54  config = mkIf cfg.enable {
55    assertions = [
56      (lib.hm.assertions.assertPlatform "services.pantalaimon" pkgs
57        lib.platforms.linux)
58    ];
59
60    home.packages = [ cfg.package ];
61
62    systemd.user.services = {
63      pantalaimon = {
64        Unit = {
65          Description =
66            "Pantalaimon - E2EE aware proxy daemon for matrix clients";
67          After = [ "network-online.target" ];
68        };
69
70        Service = {
71          ExecStart = "${cfg.package}/bin/pantalaimon -c ${
72              iniFmt.generate "pantalaimon.conf" cfg.settings
73            }";
74          Restart = "on-failure";
75        };
76
77        Install.WantedBy = [ "default.target" ];
78      };
79    };
80  };
81}