diff --git a/flake.nix b/flake.nix index ff2a685..04919d3 100755 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,7 @@ ./modules/stream.nix ./modules/nextcloud.nix ./modules/matrix.nix + ./modules/mautrix-telegram.nix ./modules/sogo.nix { fsr.enable_office_bloat = false; diff --git a/keys/pgp/fugi.asc b/keys/pgp/fugi.asc index d552962..36c786e 100755 --- a/keys/pgp/fugi.asc +++ b/keys/pgp/fugi.asc @@ -23,42 +23,29 @@ AtzqMgx0uhQvnoB4WP6LKscU+dQybRcmWvXGpJ1H67Q9sshbAJ8/M6PIkv+ixTge 9qDppPNgRQWfk4IkU070Ed2n6utwlH9T1UFtj2HfXbbs/EENlMMMGHKV5bfjLYO1 wBMOmxneME65387gCC0VyC1mODHybrncbC/0wHeW4zKsEMP7xLC2YHnQMeo+nwW/ ZbIyOAT1vSGcVGONy6Dm+o8dgmCkzxDtG+2h3VJ+oxSZXO4rhZD718HLEFLFJy31 -dra9QAZS6Id4TWBX/ssGHqfLROW9w915O5vUlMPMgWdadl+Gu/b6BLQeTHVjYXMg -RnVnbWFubiA8bHVjYXNAZnVnaS5kZXY+iQJOBBMBCAA4AhsDBQsJCAcCBhUKCQgL -AgQWAgMBAh4BAheAFiEEvzeQOub9KUxMZ07iRHKiAJG/p5IFAmO7DR8ACgkQRHKi -AJG/p5KGYRAAoAGdF9xjBXt3XNRTQapCelA/GeNtUTTqd7AsEeTe2vpl2Wro+mqw -d77997LzugxrqEOxmMTp8aqeu5eg7QZbYxIWRDESzIfLu3/mFK7RWtwUMnq9E+Nw -1+6TM3r/wIg6vY6fLFZpUmnL3M7BXEBynCWXy0N39BtzcTD8SxYCco8Ud0ZD2Ike -Pt/5xN5WHs+FyII4mUo8TDwW8hQbyMOQGu06prkG8NHn5PVQk3Fc4aqAwfYl9PaS -GTfvz3POEL2+7e9cbc7wUaG6W0wVtS97j4BRLmDn2HmfcD611TX0Axfoji3wevYi -2wvxidnVbvVUYpEq7cJ2XYBcE4gGTSADr6Sn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1CDZf3tPfIEuW7STcU5GJeK60kXbLYWsu +ktWMG81950zHmkidnVRx+6Afem0IyoE/oXyqQxmbpZc+I/j/7w5s3UnMfBSLT4CU +RKDxUzrpsELRTjEJfEhSFM1G0AIm3d7uOSM0sAo8bstC +=dj40 -----END PGP PUBLIC KEY BLOCK----- diff --git a/modules/mautrix-telegram.nix b/modules/mautrix-telegram.nix new file mode 100644 index 0000000..105a7a2 --- /dev/null +++ b/modules/mautrix-telegram.nix @@ -0,0 +1,71 @@ +{ config, options, lib, pkgs, ... }: +let + homeserverDomain = config.services.matrix-synapse.settings.server_name; + registrationFileSynapse = "/var/lib/matrix-synapse/telegram-registration.yaml"; + registrationFileMautrix = "/var/lib/mautrix-telegram/telegram-registration.yaml"; + settingsFile = builtins.head (builtins.match ".*--config='(.*)' \\\\.*" config.systemd.services.mautrix-telegram.preStart); +in +{ + services.postgresql = { + enable = true; + ensureUsers = [{ + name = "mautrix-telegram"; + ensurePermissions = { + "DATABASE \"mautrix-telegram\"" = "ALL PRIVILEGES"; + }; + }]; + ensureDatabases = [ "mautrix-telegram" ]; + }; + + sops.secrets.mautrix-telegram_env = { }; + + services.matrix-synapse.settings.app_service_config_files = [ + # The registration file is automatically generated after starting the + # appservice for the first time. + registrationFileSynapse + ]; + + systemd.tmpfiles.rules = [ + # copy registration file over to synapse + "C ${registrationFileSynapse} - - - - ${registrationFileMautrix}" + "Z /var/lib/matrix-synapse/ - matrix-synapse matrix-synapse - -" + ]; + + services.mautrix-telegram = { + enable = true; + + environmentFile = config.sops.secrets.mautrix-telegram_env.path; + + settings = { + homeserver = { + address = "http://[::1]:8008"; + domain = homeserverDomain; + }; + + appservice = rec { + # Use postgresql instead of sqlite + database = "postgresql:///mautrix-telegram?host=/run/postgresql"; + port = 8082; + address = "localhost:${toString port}"; + }; + + bridge = { + relaybot.authless_portals = false; + permissions = { + "@admin:${homeserverDomain}" = "admin"; + }; + relay_user_distinguishers = [ ]; + }; + }; + }; + + # If we don't explicitly set {a,h}s_token, mautrix-telegram will try to read them from the registrationFile + # and write them to the settingsFile in /nix/store, which obviously fails. + systemd.services.mautrix-telegram.serviceConfig.ExecStart = + lib.mkForce (pkgs.writeShellScript "start" '' + export MAUTRIX_TELEGRAM_APPSERVICE_AS_TOKEN=$(grep as_token ${registrationFileMautrix} | cut -d' ' -f2-) + export MAUTRIX_TELEGRAM_APPSERVICE_HS_TOKEN=$(grep hs_token ${registrationFileMautrix} | cut -d' ' -f2-) + + ${pkgs.mautrix-telegram}/bin/mautrix-telegram --config='${settingsFile}' + ''); +} diff --git a/secrets/quitte.yaml b/secrets/quitte.yaml index 3bf0826..70daf77 100644 --- a/secrets/quitte.yaml +++ b/secrets/quitte.yaml @@ -16,6 +16,7 @@ mediawiki: initial_admin: ENC[AES256_GCM,data:iET5rz9rygx49NDBjKwqAlRgpeS+jq5iM5zmjnoKcyk=,iv:11iDbCrpzjCdyAB22R8NknJ6vzcpVZXCXB3iWsGWXw0=,tag:1RCyg1ysOWaXKdqqdHqRrw==,type:str] ldapprovider: ENC[AES256_GCM,data:CPsrWmUviUpFIVVN/2a1lRjJCoZCWR9zrHm3T5Tv/YuXSYXStZGfBgXN96zhJUUpZcwiJq95o1sajyit+6itZCcGAPu0BTHSnNXRu1fgifonXE0ghw6rvzwkYpfBS+rfmBcG2wxX+7uZG3ulANYpvvGMxpKgM5IzQjE1sAytRDir6QeMGcFHP2gV4xQAdTNUZK2V+EKOlrcV5vTSzDSy3eXg18TVUgZqdxaQFfwnr2UN0eEEZ4Dn83G3QWsROZ0A7R3tuEmdAzmR8AdWBxfqCcOA8vZaOIOWb1AyobLCUaqQOj/SbGdgehMOQn1UcbRHpYQ2E9mvxD572uc/U5kzy/TbOLM34pkvckNrGfxwvqwbvXZrVP3gONY5CnJpk5XfVdT5Au/uwE5ZRs83ZEx31+85mpK3HecyBWRfWID0z2XS8PAU6G7ASQsXCh6sd5LFhL7zhxBQ4ENjT8pDi0OLYvw9VzPhPrdzooULeMytGitVWRtLsSzCn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hLtVWYEOFW2Nf8uLY8qkNLuDzA6bYx8rn3CEXoxiv0n4,iv:jmcWTyVkqu9nDc1ws2NxkMKrHPZ13i3jqDkk4Y0kejw=,tag:BjhmPc4lSbsZBmZ/q2CqGg==,type:str] sops: kms: [] gcp_kms: [] @@ -31,8 +32,8 @@ sops: NEJBTHE2end1RDlHRTNFYlZjTjhib2cKmQRHpBKZ2DbQ5CfOwcSPfZAm9fnnpxUk +LcR8haK//O3N2uNf9etDW3VsT5ipPucCdFU1m/v9L5tcN6ZP8WP+w== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-07-03T16:18:44Z" - mac: ENC[AES256_GCM,data:USYbcrCkagxH2fMkkYab6kviwvaM9dC6BHd+uomsjQQwp2aSElxrz7yJZgHiiWuODwLqC6Cg+i/1NLY1JDyGy1IBehmaW/PFEjpq5RjcY4oIiHWDLBKlVBryZGMlDCc1o5Q5ispK8TksCDP567ogEV1AeFb/f/l4Lp/0lsstQlk=,iv:oyIndbLisTKyJezd0ndpuHesAur57g5d0vZb/nliGfs=,tag:K/hWbcikN1ATgJrzABWD9Q==,type:str] + lastmodified: "2023-07-04T07:41:45Z" + mac: ENC[AES256_GCM,data:YLC02dhSSLl9C1B7wo/AJcY4a4zc1LIaA0PKH0H8uZ8I9Kh105yk4sc2cz15FVMLtkMeIdfnhmWxbnPyLbM0mA9bAYT9MQn65quEgDumr+XH0UW6m1e2S23/2fxTFH1xRWsu7/Kon/gdzLb5hf2m30eJAP7MrdpxDz28Q7ut1P4=,iv:9UC71WxpDt1bxWSu16Sc+OKpy6KmX0Ru+Q54LYuQCBU=,tag:CpNKSJem+XHimm+yzRpwaw==,type:str] pgp: - created_at: "2023-04-23T17:48:54Z" enc: | diff --git a/secrets/test.yaml b/secrets/test.yaml index e68e340..22f0d57 100644 --- a/secrets/test.yaml +++ b/secrets/test.yaml @@ -15,6 +15,7 @@ mediawiki: postgres: ENC[AES256_GCM,data:bna6ksGVOHWor7OqVL/jgeDIxA==,iv:bgkQh+NgPE/hr4N4YOCzSCfs7vaOx4pSWlc8WxI8qMc=,tag:WIjyu1i0M7flGFFovH5jWQ==,type:str] initial_admin: ENC[AES256_GCM,data:YRd3O5774NTmshxbQPbFjg==,iv:/Ra3WbZKcnUMf99ujN9qd/+DkOkFKv4cIEfUdmxpqMw=,tag:gj7ZbwIB1HLuPpGTgiz7Vg==,type:str] ldapprovider: ENC[AES256_GCM,data:dVrCFVgm4BDtUhcj9rSKXwnaIKsC5GGsDUoPJH1q5F4inskuSbFigcLM/UJFNOcr5R1dL+mYUOvnmIcoWA5AsuFKs3NzSYJVtVAm0x7vYSkHnfXu93V2F8Lc1xX/kZrFfnmNUXwhv2I+hknPUApY7wpmZOdk9NLKv4tbsgVTbfmR/WM6soOurh3b6b4cknfxqSeLZLeOIKL5WL8842t5SethyCfPsCm74JCpwHmflkCyT/lzIP1Kghab+xGWWyN9OAENlDZrJE6VAdctR+MKYZnhA7dXKeQPjKii9MZsDYFYTL5YDRysam4r7Jog/fozgWkXNrCUan29efnnBwpLz5hgV1MguIpvU8ccDQLNvgJCOdp6FgH45ZRlCxx29EWzh9iTDGPqmNsctUknFdfUVfIg9ziz/97i/kGcwy5N1oOsoUf7iRj5zLyLP6OlXGNThowF4jlNdI2b+caQGz7H6ZkJfUPWULotBUrjxrZo3pSYRkpJ77xbGUZf35ysxTHpfsmhyyO9HRhhgNkilEHlcsi8u+AC0su+Htg/Io332tSX+W6Gj6R6Q23hQ0gf8on5Y2xx34ysobEh8cMS4+Kj0nwasMHjW70g3qWpKkG1LSOIgXiA7hcusGCo8xPZ1y3gIyRiTxVTPJHh63Ecd0O37P4NWVSKEpsIM5pkngMN5L5K/ymtZ0kjREX2q4qpXf2xJiTTdAkeTMcmDs9HHjOzIIynYouY7P6qdXUpXjyGwqfovmnIv5icQ6sqFA==,iv:sPRnnIEif6W1SPy5SKiUuY681HeLPcR19U4p1mdUGdc=,tag:zeMdtTRk8ULP4GYDQLIU7A==,type:str] +mautrix-telegram_env: ENC[AES256_GCM,data:vqHmM3mRrIYMT4760sglAlBZoOb7siqx3alvQE5rpq8z6FgOqJxHqGaN1quhpAVVe9ugtlvezVh8eSFX+45Y5rtqJ7iylxmC+y8JGsyLIflf674Si7h07bedCcT0wBg1ioI/JILDwICiAf0=,iv:BAPKiVt2l3E7z1Wk9ky6WFYr6hn62d+X5r0NMdUYwJQ=,tag:CRddpVMHQLwhwUF1hn0JKA==,type:str] sops: kms: [] gcp_kms: [] @@ -30,8 +31,8 @@ sops: MERVUkh2ck9YWnJ5TXJDVmxpem1kTXMKCeOyjV/se1nRXsi15m/3i48hP7As6SEk ygtLt+UueHStX/b/OzrXk8IC5dj/mARGIJI5S61IKln6SZFbJGT6cQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-04-03T21:29:36Z" - mac: ENC[AES256_GCM,data:tsnXkf9D/EzNozBWEK8fca0S+vSc4fH0y9KXpjlYtcFkgjSjvuwnlo2tH3stdEAo5odHO/rsW29uCvCDomTHwMUeKWmD7NdUAVbBuUNfl6pl6gll9p+9yfTB5lZH9QpFGnC/6ANbwhLN7vBO5ZCRbfpl5hlIN4iQ25GyiPZ/GCM=,iv:2YWxDXfsonj+Td/ZeEBKZYuDpGktEVYw1LBPxqIyofA=,tag:aaX98g7PtGh5Ob81EWmHcA==,type:str] + lastmodified: "2023-05-04T14:41:09Z" + mac: ENC[AES256_GCM,data:qY1fcRl53tcvgYAqhvWLfAxe6MRvcXcbkeLMtQShQtyKRv4BW0AMOh0OOKFcxxcMbucG4j9yufvK18Q8COIslsOtm5wZhEjK8+sK0RT3l6uX0EPn/aNwGWwScXjMOeKJEBEozA4xPHt7+flTsRDAzjRz+ixC/cevm1Iu/ok17lE=,iv:OTtpuinzQXZ6nykpH8/XwIUYDNf+DNWrbDxCmJpdqAc=,tag:ng3dWwOdj60iy4yT4Ux8Cw==,type:str] pgp: - created_at: "2022-11-18T16:37:58Z" enc: |