Skip to content

Commit a5b05d7

Browse files
committed
develop: matrix-synapse: new bridge configs
1 parent c645a45 commit a5b05d7

File tree

2 files changed

+70
-57
lines changed

2 files changed

+70
-57
lines changed

modules/nixos/matrix-synapse/bridges/signal.nix

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
let
99
cfg = config.services.matrix-synapse;
10-
port = 8008;
10+
matrixPort = 8008;
1111
fqdn = "${config.networking.domain}";
1212
olmVersion = "3.2.16";
1313

14-
signal = cfg.bridges.signal;
14+
bridge = cfg.bridges.signal;
1515

1616
inherit (lib)
17+
mkDefault
1718
mkEnableOption
1819
mkIf
1920
mkOption
@@ -27,15 +28,14 @@ in
2728
enable = mkEnableOption "Enable mautrix-signal for your matrix-synapse instance.";
2829
admin = mkOption {
2930
type = types.str;
30-
default = "";
3131
description = "The user to give admin permissions to.";
3232
example = "@admin:example.com";
3333
};
3434
};
3535
};
3636
};
3737

38-
config = mkIf (cfg.enable && signal.enable) {
38+
config = mkIf (cfg.enable && bridge.enable) {
3939
nixpkgs = {
4040
config.permittedInsecurePackages = [ "olm-${olmVersion}" ];
4141
};
@@ -45,35 +45,40 @@ in
4545
services.mautrix-signal = {
4646
enable = true;
4747
settings = {
48-
homeserver = {
49-
address = "http://localhost:${toString port}";
48+
network = {
49+
displayname_template = mkDefault "{{or .ContactName .ProfileName .PhoneNumber \"Unknown user\" }} (S)";
5050
};
5151
bridge = {
52-
encryption = {
53-
allow = true;
54-
default = true;
55-
require = true;
56-
};
57-
double_puppet_server_map = {
58-
"${cfg.settings.server_name}" = "https://${cfg.settings.server_name}";
59-
};
60-
history_sync = {
61-
request_full_sync = true;
62-
};
63-
mute_bridging = true;
64-
network = {
65-
displayname_template = "{{or .ContactName .ProfileName .PhoneNumber}} (S)";
66-
};
6752
permissions = {
68-
"*" = "relay";
69-
"${fqdn}" = "user";
70-
"${signal.admin}" = mkIf (signal.admin != "") "admin";
71-
};
72-
private_chat_portal_meta = true;
73-
provisioning = {
74-
shared_secret = "disable";
53+
"*" = mkDefault "relay";
54+
"${fqdn}" = mkDefault "user";
55+
"${bridge.admin}" = mkDefault "admin";
7556
};
7657
};
58+
homeserver = {
59+
address = mkDefault "http://localhost:${toString matrixPort}";
60+
domain = mkDefault fqdn;
61+
};
62+
appservice = {
63+
address = mkDefault "http://localhost:${toString bridge.settings.appservice.port}";
64+
public_address = mkDefault "https://${fqdn}";
65+
hostname = mkDefault "localhost";
66+
port = mkDefault 29318;
67+
};
68+
public_media = {
69+
enabled = mkDefault false;
70+
};
71+
direct_media = {
72+
enabled = mkDefault false;
73+
};
74+
backfill = {
75+
enabled = mkDefault true;
76+
};
77+
encryption = {
78+
allow = mkDefault true;
79+
default = mkDefault true;
80+
require = mkDefault true;
81+
};
7782
};
7883
};
7984
};

modules/nixos/matrix-synapse/bridges/whatsapp.nix

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
let
99
cfg = config.services.matrix-synapse;
10-
port = 8008;
11-
fqdn = "${config.networking.domain}";
10+
matrixPort = 8008;
11+
fqdn = config.networking.domain;
1212
olmVersion = "3.2.16";
1313

14-
whatsapp = cfg.bridges.whatsapp;
14+
bridge = cfg.bridges.whatsapp;
1515

1616
inherit (lib)
17+
mkDefault
1718
mkEnableOption
1819
mkIf
1920
mkOption
@@ -27,15 +28,14 @@ in
2728
enable = mkEnableOption "Enable mautrix-whatsapp for your matrix-synapse instance.";
2829
admin = mkOption {
2930
type = types.str;
30-
default = "";
3131
description = "The user to give admin permissions to.";
3232
example = "@admin:example.com";
3333
};
3434
};
3535
};
3636
};
3737

38-
config = mkIf (cfg.enable && whatsapp.enable) {
38+
config = mkIf (cfg.enable && bridge.enable) {
3939
nixpkgs = {
4040
config.permittedInsecurePackages = [ "olm-${olmVersion}" ];
4141
};
@@ -45,35 +45,43 @@ in
4545
services.mautrix-whatsapp = {
4646
enable = true;
4747
settings = {
48-
homeserver = {
49-
address = "http://localhost:${toString port}";
50-
};
51-
bridge = {
52-
encryption = {
53-
allow = true;
54-
default = true;
55-
require = true;
56-
};
57-
double_puppet_server_map = {
58-
"${cfg.settings.server_name}" = "https://${cfg.settings.server_name}";
59-
};
48+
network = {
49+
displayname_template = mkDefault "{{or .FullName .BusinessName .PushName .Phone}} (WA)";
6050
history_sync = {
61-
request_full_sync = true;
51+
request_full_sync = mkDefault true;
6252
};
63-
mute_bridging = true;
64-
displayname_template = "{{or .FullName .BusinessName .PushName .Phone}} (WA)";
65-
user_avatar_sync = true;
66-
url_previews = false;
53+
};
54+
bridge = {
6755
permissions = {
68-
"*" = "relay";
69-
"${fqdn}" = "user";
70-
"${whatsapp.admin}" = mkIf (whatsapp.admin != "") "admin";
71-
};
72-
private_chat_portal_meta = true;
73-
provisioning = {
74-
shared_secret = "disable";
56+
"*" = mkDefault "relay";
57+
"${fqdn}" = mkDefault "user";
58+
"${bridge.admin}" = mkDefault "admin";
7559
};
7660
};
61+
homeserver = {
62+
address = mkDefault "http://localhost:${toString matrixPort}";
63+
domain = mkDefault fqdn;
64+
};
65+
appservice = {
66+
address = mkDefault "http://localhost:${toString bridge.settings.appservice.port}";
67+
public_address = mkDefault "https://${fqdn}";
68+
hostname = mkDefault "localhost";
69+
port = mkDefault 29318;
70+
};
71+
public_media = {
72+
enabled = mkDefault false;
73+
};
74+
direct_media = {
75+
enabled = mkDefault false;
76+
};
77+
backfill = {
78+
enabled = mkDefault true;
79+
};
80+
encryption = {
81+
allow = mkDefault true;
82+
default = mkDefault true;
83+
require = mkDefault true;
84+
};
7785
};
7886
};
7987
};

0 commit comments

Comments
 (0)