Compare commits
28 commits
6bae135b1b
...
3319dcb26a
| Author | SHA1 | Date | |
|---|---|---|---|
| 3319dcb26a | |||
| 27639d4672 | |||
| d548cd925f | |||
| 482be0f986 | |||
| 57fb7ed919 | |||
| 6ddcbef358 | |||
| 2f952be60f | |||
| a2b9fd42a1 | |||
| 5bb44532c6 | |||
| b41dc777a1 | |||
| c07c586503 | |||
| 62c4d5a114 | |||
| 313b2552cb | |||
| 17ceaa5620 | |||
| b1c9279c63 | |||
| 30348a1e19 | |||
| 7a85a44407 | |||
| 9cadbe6256 | |||
| fa7b4910f5 | |||
| 1e31b2dfea | |||
| bd019258cb | |||
| 0792e8c7cb | |||
| f1d7da7fcb | |||
| dd7b613531 | |||
| a10270f8e1 | |||
| f94fc468aa | |||
| 7786c591b5 | |||
| 4b7c6c1f5e |
9 changed files with 309 additions and 132 deletions
30
flake.lock
generated
30
flake.lock
generated
|
|
@ -14,11 +14,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1750173260,
|
"lastModified": 1754337839,
|
||||||
"narHash": "sha256-9P1FziAwl5+3edkfFcr5HeGtQUtrSdk/MksX39GieoA=",
|
"narHash": "sha256-fEc2/4YsJwtnLU7HCFMRckb0u9UNnDZmwGhXT5U5NTw=",
|
||||||
"owner": "ryantm",
|
"owner": "ryantm",
|
||||||
"repo": "agenix",
|
"repo": "agenix",
|
||||||
"rev": "531beac616433bac6f9e2a19feb8e99a22a66baf",
|
"rev": "856df6f6922845abd4fd958ce21febc07ca2fa45",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -73,11 +73,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1753121425,
|
"lastModified": 1754091436,
|
||||||
"narHash": "sha256-TVcTNvOeWWk1DXljFxVRp+E0tzG1LhrVjOGGoMHuXio=",
|
"narHash": "sha256-XKqDMN1/Qj1DKivQvscI4vmHfDfvYR2pfuFOJiCeewM=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "644e0fc48951a860279da645ba77fe4a6e814c5e",
|
"rev": "67df8c627c2c39c41dbec76a1f201929929ab0bd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -159,11 +159,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1753617834,
|
"lastModified": 1754365350,
|
||||||
"narHash": "sha256-WEVfKrdIdu5CpppJ0Va3vzP0DKlS+ZTLbBjugMO2Drg=",
|
"narHash": "sha256-NLWIkn1qM0wxtZu/2NXRaujWJ4Y1PSZlc7h0y6pOzOQ=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "72cc1e3134a35005006f06640724319caa424737",
|
"rev": "c5d7e957397ecb7d48b99c928611c6e780db1b56",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -175,11 +175,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1753429684,
|
"lastModified": 1754372978,
|
||||||
"narHash": "sha256-9h7+4/53cSfQ/uA3pSvCaBepmZaz/dLlLVJnbQ+SJjk=",
|
"narHash": "sha256-ByII9p9ek0k9UADC/hT+i9ueM2mw0Zxiz+bOlydU6Oo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7fd36ee82c0275fb545775cc5e4d30542899511d",
|
"rev": "9ebe222ec7ef9de52478f76cba3f0324c1d1119f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -200,11 +200,11 @@
|
||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1741294988,
|
"lastModified": 1753980880,
|
||||||
"narHash": "sha256-3408u6q615kVTb23WtDriHRmCBBpwX7iau6rvfipcu4=",
|
"narHash": "sha256-aj1pbYxL6N+XFqBHjB4B1QP0bnKRcg1AfpgT5zUFsW8=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "NUR",
|
"repo": "NUR",
|
||||||
"rev": "b30c245e2c44c7352a27485bfd5bc483df660f0e",
|
"rev": "16db3e61da7606984a05b4dfc33cd1d26d22fb22",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ in
|
||||||
spreadsheet = "spreadsheet editor";
|
spreadsheet = "spreadsheet editor";
|
||||||
text = "word processor";
|
text = "word processor";
|
||||||
};
|
};
|
||||||
terminal = "terminal";
|
terminal = "terminal"; # FIXME: should it also set `xdg.terminal-exec.settings.default`?
|
||||||
torrent = "bittorrent client";
|
torrent = "bittorrent client";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,12 @@ in
|
||||||
exclude = mkOption {
|
exclude = mkOption {
|
||||||
type = with types; listOf str;
|
type = with types; listOf str;
|
||||||
default = [
|
default = [
|
||||||
|
"bat"
|
||||||
"delta"
|
"delta"
|
||||||
"direnv reload"
|
"direnv reload"
|
||||||
"fg"
|
"fg"
|
||||||
"git (?!push|pull|fetch)"
|
"git (?!push|pull|fetch)"
|
||||||
|
"home-manager (?!switch|build|news)"
|
||||||
"htop"
|
"htop"
|
||||||
"less"
|
"less"
|
||||||
"man"
|
"man"
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
./servarr
|
./servarr
|
||||||
./ssh-server
|
./ssh-server
|
||||||
./tandoor-recipes
|
./tandoor-recipes
|
||||||
|
./thelounge
|
||||||
./tlp
|
./tlp
|
||||||
./transmission
|
./transmission
|
||||||
./vikunja
|
./vikunja
|
||||||
|
|
|
||||||
143
modules/nixos/services/matrix/bridges.nix
Normal file
143
modules/nixos/services/matrix/bridges.nix
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
# Matrix bridges for some services I use
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.my.services.matrix.bridges;
|
||||||
|
synapseCfg = config.services.matrix-synapse;
|
||||||
|
|
||||||
|
domain = config.networking.domain;
|
||||||
|
serverName = synapseCfg.settings.server_name;
|
||||||
|
|
||||||
|
mkBridgeOption = n: lib.mkEnableOption "${n} bridge" // { default = cfg.enable; };
|
||||||
|
mkPortOption = n: default: lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
inherit default;
|
||||||
|
example = 8080;
|
||||||
|
description = "${n} bridge port";
|
||||||
|
};
|
||||||
|
mkEnvironmentFileOption = n: lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
example = "/run/secret/matrix/${lib.toLower n}-bridge-secrets.env";
|
||||||
|
description = ''
|
||||||
|
Path to a file which should contain the secret values for ${n} bridge.
|
||||||
|
|
||||||
|
Using through the following format:
|
||||||
|
|
||||||
|
```
|
||||||
|
MATRIX_APPSERVICE_AS_TOKEN=<the_as_value>
|
||||||
|
MATRIX_APPSERVICE_HS_TOKEN=<the_hs_value>
|
||||||
|
```
|
||||||
|
|
||||||
|
Each bridge should use a different set of secrets, as they each register
|
||||||
|
their own independent double-puppetting appservice.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.services.matrix.bridges = with lib; {
|
||||||
|
enable = mkEnableOption "bridges configuration";
|
||||||
|
|
||||||
|
admin = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "ambroisie";
|
||||||
|
example = "admin";
|
||||||
|
description = "Local username for the admin";
|
||||||
|
};
|
||||||
|
|
||||||
|
facebook = {
|
||||||
|
enable = mkBridgeOption "Facebook";
|
||||||
|
|
||||||
|
port = mkPortOption "Facebook" 29321;
|
||||||
|
|
||||||
|
environmentFile = mkEnvironmentFileOption "Facebook";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkMerge [
|
||||||
|
(lib.mkIf cfg.facebook.enable {
|
||||||
|
services.mautrix-meta.instances.facebook = {
|
||||||
|
enable = true;
|
||||||
|
# Automatically register the bridge with synapse
|
||||||
|
registerToSynapse = true;
|
||||||
|
|
||||||
|
# Provide `AS_TOKEN`, `HS_TOKEN`
|
||||||
|
inherit (cfg.facebook) environmentFile;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
homeserver = {
|
||||||
|
domain = serverName;
|
||||||
|
address = "http://localhost:${toString config.my.services.matrix.port}";
|
||||||
|
};
|
||||||
|
|
||||||
|
appservice = {
|
||||||
|
hostname = "localhost";
|
||||||
|
inherit (cfg.facebook) port;
|
||||||
|
address = "http://localhost:${toString cfg.facebook.port}";
|
||||||
|
public_address = "https://facebook-bridge.${domain}";
|
||||||
|
|
||||||
|
as_token = "$MATRIX_APPSERVICE_AS_TOKEN";
|
||||||
|
hs_token = "$MATRIX_APPSERVICE_HS_TOKEN";
|
||||||
|
|
||||||
|
bot = {
|
||||||
|
username = "fbbot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
backfill = {
|
||||||
|
enabled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
bridge = {
|
||||||
|
delivery_receipts = true;
|
||||||
|
permissions = {
|
||||||
|
"*" = "relay";
|
||||||
|
${serverName} = "user";
|
||||||
|
"@${cfg.admin}:${serverName}" = "admin";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
database = {
|
||||||
|
type = "postgres";
|
||||||
|
uri = "postgres:///mautrix-meta-facebook?host=/var/run/postgresql/";
|
||||||
|
};
|
||||||
|
|
||||||
|
double_puppet = {
|
||||||
|
secrets = {
|
||||||
|
${serverName} = "as_token:$MATRIX_APPSERVICE_AS_TOKEN";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
network = {
|
||||||
|
# Don't be picky on Facebook/Messenger
|
||||||
|
allow_messenger_com_on_fb = true;
|
||||||
|
displayname_template = ''{{or .DisplayName .Username "Unknown user"}} (FB)'';
|
||||||
|
};
|
||||||
|
|
||||||
|
provisioning = {
|
||||||
|
shared_secret = "disable";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.postgresql = {
|
||||||
|
enable = true;
|
||||||
|
ensureDatabases = [ "mautrix-meta-facebook" ];
|
||||||
|
ensureUsers = [{
|
||||||
|
name = "mautrix-meta-facebook";
|
||||||
|
ensureDBOwnership = true;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.mautrix-meta-facebook = {
|
||||||
|
wants = [ "postgres.service" ];
|
||||||
|
after = [ "postgres.service" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
my.services.nginx.virtualHosts = {
|
||||||
|
# Proxy to the bridge
|
||||||
|
"facebook-bridge" = {
|
||||||
|
inherit (cfg.facebook) port;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -1,24 +1,49 @@
|
||||||
# Matrix homeserver setup, using different endpoints for federation and client
|
# Matrix homeserver setup.
|
||||||
# traffic. The main trick for this is defining two nginx servers endpoints for
|
|
||||||
# matrix.domain.com, each listening on different ports.
|
|
||||||
#
|
|
||||||
# Configuration shamelessly stolen from [1]
|
|
||||||
#
|
|
||||||
# [1]: https://github.com/alarsyo/nixos-config/blob/main/services/matrix.nix
|
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.my.services.matrix;
|
cfg = config.my.services.matrix;
|
||||||
|
|
||||||
federationPort = { public = 8448; private = 11338; };
|
adminPkg = pkgs.synapse-admin-etkecc;
|
||||||
clientPort = { public = 443; private = 11339; };
|
|
||||||
domain = config.networking.domain;
|
domain = config.networking.domain;
|
||||||
matrixDomain = "matrix.${domain}";
|
matrixDomain = "matrix.${domain}";
|
||||||
|
|
||||||
|
serverConfig = {
|
||||||
|
"m.server" = "${matrixDomain}:443";
|
||||||
|
};
|
||||||
|
clientConfig = {
|
||||||
|
"m.homeserver" = {
|
||||||
|
"base_url" = "https://${matrixDomain}";
|
||||||
|
"server_name" = domain;
|
||||||
|
};
|
||||||
|
"m.identity_server" = {
|
||||||
|
"base_url" = "https://vector.im";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# ACAO required to allow element-web on any URL to request this json file
|
||||||
|
mkWellKnown = data: ''
|
||||||
|
default_type application/json;
|
||||||
|
add_header Access-Control-Allow-Origin *;
|
||||||
|
return 200 '${builtins.toJSON data}';
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
./bridges.nix
|
||||||
|
];
|
||||||
|
|
||||||
options.my.services.matrix = with lib; {
|
options.my.services.matrix = with lib; {
|
||||||
enable = mkEnableOption "Matrix Synapse";
|
enable = mkEnableOption "Matrix Synapse";
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
default = 8448;
|
||||||
|
example = 8008;
|
||||||
|
description = "Internal port for listeners";
|
||||||
|
};
|
||||||
|
|
||||||
secretFile = mkOption {
|
secretFile = mkOption {
|
||||||
type = with types; nullOr str;
|
type = with types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
|
|
@ -58,22 +83,22 @@ in
|
||||||
enable_registration = false;
|
enable_registration = false;
|
||||||
|
|
||||||
listeners = [
|
listeners = [
|
||||||
# Federation
|
|
||||||
{
|
{
|
||||||
|
inherit (cfg) port;
|
||||||
bind_addresses = [ "::1" ];
|
bind_addresses = [ "::1" ];
|
||||||
port = federationPort.private;
|
type = "http";
|
||||||
tls = false; # Terminated by nginx.
|
tls = false;
|
||||||
x_forwarded = true;
|
x_forwarded = true;
|
||||||
resources = [{ names = [ "federation" ]; compress = false; }];
|
resources = [
|
||||||
}
|
{
|
||||||
|
names = [ "client" ];
|
||||||
# Client
|
compress = true;
|
||||||
{
|
}
|
||||||
bind_addresses = [ "::1" ];
|
{
|
||||||
port = clientPort.private;
|
names = [ "federation" ];
|
||||||
tls = false; # Terminated by nginx.
|
compress = false;
|
||||||
x_forwarded = true;
|
}
|
||||||
resources = [{ names = [ "client" ]; compress = false; }];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -96,19 +121,12 @@ in
|
||||||
chat = {
|
chat = {
|
||||||
root = pkgs.element-web.override {
|
root = pkgs.element-web.override {
|
||||||
conf = {
|
conf = {
|
||||||
default_server_config = {
|
default_server_config = clientConfig;
|
||||||
"m.homeserver" = {
|
show_labs_settings = true;
|
||||||
"base_url" = "https://${matrixDomain}";
|
default_country_code = "FR"; # cocorico
|
||||||
"server_name" = domain;
|
room_directory = {
|
||||||
};
|
|
||||||
"m.identity_server" = {
|
|
||||||
"base_url" = "https://vector.im";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
showLabsSettings = true;
|
|
||||||
defaultCountryCode = "FR"; # cocorico
|
|
||||||
roomDirectory = {
|
|
||||||
"servers" = [
|
"servers" = [
|
||||||
|
domain
|
||||||
"matrix.org"
|
"matrix.org"
|
||||||
"mozilla.org"
|
"mozilla.org"
|
||||||
];
|
];
|
||||||
|
|
@ -116,99 +134,54 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# Dummy VHosts for port collision detection
|
matrix = {
|
||||||
matrix-federation = {
|
# Somewhat unused, but necessary for port collision detection
|
||||||
port = federationPort.private;
|
inherit (cfg) port;
|
||||||
};
|
|
||||||
matrix-client = {
|
extraConfig = {
|
||||||
port = clientPort.private;
|
locations = {
|
||||||
|
# Or do a redirect instead of the 404, or whatever is appropriate
|
||||||
|
# for you. But do not put a Matrix Web client here! See the
|
||||||
|
# Element web section above.
|
||||||
|
"/".return = "404";
|
||||||
|
|
||||||
|
"/_matrix".proxyPass = "http://[::1]:${toString cfg.port}";
|
||||||
|
"/_synapse".proxyPass = "http://[::1]:${toString cfg.port}";
|
||||||
|
|
||||||
|
"= /admin".return = "307 /admin/";
|
||||||
|
"/admin/" = {
|
||||||
|
alias = "${adminPkg}/";
|
||||||
|
priority = 500;
|
||||||
|
tryFiles = "$uri $uri/ /index.html";
|
||||||
|
};
|
||||||
|
"~ ^/admin/.*\\.(?:css|js|jpg|jpeg|gif|png|svg|ico|woff|woff2|ttf|eot|webp)$" = {
|
||||||
|
priority = 400;
|
||||||
|
root = adminPkg;
|
||||||
|
extraConfig = ''
|
||||||
|
rewrite ^/admin/(.*)$ /$1 break;
|
||||||
|
expires 30d;
|
||||||
|
more_set_headers "Cache-Control: public";
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Those are too complicated to use my wrapper...
|
# Setup well-known locations
|
||||||
services.nginx.virtualHosts = {
|
services.nginx.virtualHosts = {
|
||||||
${matrixDomain} = {
|
|
||||||
onlySSL = true;
|
|
||||||
useACMEHost = domain;
|
|
||||||
|
|
||||||
locations =
|
|
||||||
let
|
|
||||||
proxyToClientPort = {
|
|
||||||
proxyPass = "http://[::1]:${toString clientPort.private}";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# Or do a redirect instead of the 404, or whatever is appropriate
|
|
||||||
# for you. But do not put a Matrix Web client here! See the
|
|
||||||
# Element web section below.
|
|
||||||
"/".return = "404";
|
|
||||||
|
|
||||||
"/_matrix" = proxyToClientPort;
|
|
||||||
"/_synapse/client" = proxyToClientPort;
|
|
||||||
};
|
|
||||||
|
|
||||||
listen = [
|
|
||||||
{ addr = "0.0.0.0"; port = clientPort.public; ssl = true; }
|
|
||||||
{ addr = "[::]"; port = clientPort.public; ssl = true; }
|
|
||||||
];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
# same as above, but listening on the federation port
|
|
||||||
"${matrixDomain}_federation" = {
|
|
||||||
onlySSL = true;
|
|
||||||
serverName = matrixDomain;
|
|
||||||
useACMEHost = domain;
|
|
||||||
|
|
||||||
locations."/".return = "404";
|
|
||||||
|
|
||||||
locations."/_matrix" = {
|
|
||||||
proxyPass = "http://[::1]:${toString federationPort.private}";
|
|
||||||
};
|
|
||||||
|
|
||||||
listen = [
|
|
||||||
{ addr = "0.0.0.0"; port = federationPort.public; ssl = true; }
|
|
||||||
{ addr = "[::]"; port = federationPort.public; ssl = true; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
"${domain}" = {
|
"${domain}" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
useACMEHost = domain;
|
useACMEHost = domain;
|
||||||
|
|
||||||
locations."= /.well-known/matrix/server".extraConfig =
|
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
||||||
let
|
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
||||||
server = { "m.server" = "${matrixDomain}:${toString federationPort.public}"; };
|
|
||||||
in
|
|
||||||
''
|
|
||||||
add_header Content-Type application/json;
|
|
||||||
return 200 '${builtins.toJSON server}';
|
|
||||||
'';
|
|
||||||
|
|
||||||
locations."= /.well-known/matrix/client".extraConfig =
|
|
||||||
let
|
|
||||||
client = {
|
|
||||||
"m.homeserver" = { "base_url" = "https://${matrixDomain}"; };
|
|
||||||
"m.identity_server" = { "base_url" = "https://vector.im"; };
|
|
||||||
};
|
|
||||||
# ACAO required to allow element-web on any URL to request this json file
|
|
||||||
in
|
|
||||||
''
|
|
||||||
add_header Content-Type application/json;
|
|
||||||
add_header Access-Control-Allow-Origin *;
|
|
||||||
return 200 '${builtins.toJSON client}';
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# For administration tools.
|
# For administration tools.
|
||||||
environment.systemPackages = [ pkgs.matrix-synapse ];
|
environment.systemPackages = [ pkgs.matrix-synapse ];
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [
|
|
||||||
clientPort.public
|
|
||||||
federationPort.public
|
|
||||||
];
|
|
||||||
|
|
||||||
my.services.backup = {
|
my.services.backup = {
|
||||||
paths = [
|
paths = [
|
||||||
config.services.matrix-synapse.dataDir
|
config.services.matrix-synapse.dataDir
|
||||||
|
|
|
||||||
59
modules/nixos/services/thelounge/default.nix
Normal file
59
modules/nixos/services/thelounge/default.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
# Web IRC client
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.my.services.thelounge;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.services.thelounge = with lib; {
|
||||||
|
enable = mkEnableOption "The Lounge, a self-hosted web IRC client";
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
default = 9050;
|
||||||
|
example = 4242;
|
||||||
|
description = "The port on which The Lounge will listen for incoming HTTP traffic.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
services.thelounge = {
|
||||||
|
enable = true;
|
||||||
|
inherit (cfg) port;
|
||||||
|
|
||||||
|
extraConfig = {
|
||||||
|
reverseProxy = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
my.services.nginx.virtualHosts = {
|
||||||
|
irc = {
|
||||||
|
inherit (cfg) port;
|
||||||
|
# Proxy websockets for RPC
|
||||||
|
websocketsLocations = [ "/" ];
|
||||||
|
|
||||||
|
extraConfig = {
|
||||||
|
locations."/".extraConfig = ''
|
||||||
|
proxy_read_timeout 1d;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.fail2ban.jails = {
|
||||||
|
thelounge = ''
|
||||||
|
enabled = true
|
||||||
|
filter = thelounge
|
||||||
|
port = http,https
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.etc = {
|
||||||
|
"fail2ban/filter.d/thelounge.conf".text = ''
|
||||||
|
[Definition]
|
||||||
|
failregex = Authentication failed for user .* from <HOST>$
|
||||||
|
Authentication for non existing user attempted from <HOST>$
|
||||||
|
journalmatch = _SYSTEMD_UNIT=thelounge.service
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -12,9 +12,9 @@ usage() {
|
||||||
|
|
||||||
find_program() {
|
find_program() {
|
||||||
local CANDIDATE
|
local CANDIDATE
|
||||||
CANDIDATE="$(nix-locate --top-level --minimal --at-root --whole-name "/bin/$1")"
|
CANDIDATE="$(nix-locate --minimal --at-root --whole-name "/bin/$1")"
|
||||||
if [ "$(printf '%s\n' "$CANDIDATE" | wc -l)" -gt 1 ]; then
|
if [ "$(printf '%s\n' "$CANDIDATE" | wc -l)" -gt 1 ]; then
|
||||||
CANDIDATE="$(printf '%s' "$CANDIDATE" | fzf-tmux)"
|
CANDIDATE="$(printf '%s' "$CANDIDATE" | "${COMMA_PICKER:-fzf-tmux}")"
|
||||||
fi
|
fi
|
||||||
printf '%s' "$CANDIDATE"
|
printf '%s' "$CANDIDATE"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ rustPlatform.buildRustPackage rec {
|
||||||
hash = "sha256-dunQgtap+XCK5LoSyOqIY/6p6HizBeiyPWNuCffwjDU=";
|
hash = "sha256-dunQgtap+XCK5LoSyOqIY/6p6HizBeiyPWNuCffwjDU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
useFetchCargoVendor = true;
|
|
||||||
cargoHash = "sha256-R3/N/43+bGx6acE/rhBcrk6kS5zQu8NJ1sVvKJJkK9w=";
|
cargoHash = "sha256-R3/N/43+bGx6acE/rhBcrk6kS5zQu8NJ1sVvKJJkK9w=";
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue