8 cfg = config.services.matrix-hookshot;
9 settingsFormat = pkgs.formats.yaml { };
10 configFile = settingsFormat.generate "matrix-hookshot-config.yml" cfg.settings;
14 services.matrix-hookshot = {
15 enable = lib.mkEnableOption "matrix-hookshot, a bridge between Matrix and project management services";
17 package = lib.mkPackageOption pkgs "matrix-hookshot" { };
19 registrationFile = lib.mkOption {
20 type = lib.types.path;
22 Appservice registration file.
23 As it contains secret tokens, you may not want to add this to the publicly readable Nix store.
25 example = lib.literalExpression ''
26 pkgs.writeText "matrix-hookshot-registration" \'\'
33 - regex: "@_webhooks_.*:foobar"
36 sender_localpart: hookshot
37 url: "http://localhost:9993"
43 settings = lib.mkOption {
45 {file}`config.yml` configuration as a Nix attribute set.
47 For details please see the [documentation](https://matrix-org.github.io/matrix-hookshot/latest/setup/sample-configuration.html).
51 domain = "example.com";
52 url = "http://localhost:8008";
53 mediaUrl = "https://example.com";
55 bindAddress = "127.0.0.1";
60 bindAddress = "0.0.0.0";
61 resources = [ "webhooks" ];
65 bindAddress = "localhost";
74 type = lib.types.submodule {
75 freeformType = settingsFormat.type;
77 passFile = lib.mkOption {
78 type = lib.types.path;
79 default = "/var/lib/matrix-hookshot/passkey.pem";
81 A passkey used to encrypt tokens stored inside the bridge.
82 File will be generated if not found.
89 serviceDependencies = lib.mkOption {
90 type = with lib.types; listOf str;
91 default = lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
92 defaultText = lib.literalExpression ''
93 lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
96 List of Systemd services to require and wait for when starting the application service,
97 such as the Matrix homeserver if it's running on the same host.
103 config = lib.mkIf cfg.enable {
104 systemd.services.matrix-hookshot = {
105 description = "a bridge between Matrix and multiple project management services";
107 wantedBy = [ "multi-user.target" ];
108 wants = [ "network-online.target" ] ++ cfg.serviceDependencies;
109 after = [ "network-online.target" ] ++ cfg.serviceDependencies;
112 if [ ! -f '${cfg.settings.passFile}' ]; then
113 mkdir -p $(dirname '${cfg.settings.passFile}')
114 ${pkgs.openssl}/bin/openssl genpkey -out '${cfg.settings.passFile}' -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:4096
121 ExecStart = "${cfg.package}/bin/matrix-hookshot ${configFile} ${cfg.registrationFile}";
126 meta.maintainers = with lib.maintainers; [ flandweber ];