add self-hosted matrix home server

This commit is contained in:
ulic-youthlic 2025-01-30 00:11:19 +08:00
parent 284ec3cb95
commit 732e186dcb
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
4 changed files with 67 additions and 2 deletions

View file

@ -22,6 +22,10 @@
programs = {
openssh.enable = true;
tailscale.enable = true;
conduwuit = {
enable = true;
serverName = "im.youthlic.fun";
};
caddy = {
enable = true;
baseDomain = "youthlic.fun";

View file

@ -0,0 +1,59 @@
{ config, lib, ... }:
let
cfg = config.youthlic.programs.conduwuit;
in
{
options = {
youthlic.programs.conduwuit = {
enable = lib.mkEnableOption "conduwuit";
serverName = lib.mkOption {
type = lib.types.nonEmptyStr;
example = "example.com";
};
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
sops.secrets."matrix-reg-token" = {
owner = "conduwuit";
};
systemd.services.conduwuit.serviceConfig = {
EnvironmentFile = "${config.sops.secrets.matrix-reg-token.path}";
};
services.conduwuit = {
enable = true;
settings = {
global = {
port = [ 8481 ];
address = [
"0.0.0.0"
"::"
];
trusted_servers = [
"matrix.org"
"mozilla.org"
"nichi.co"
];
allow_registration = true;
server_name = cfg.serverName;
new_user_displayname_suffix = "";
allow_public_room_directory_over_federation = true;
well_known = {
client = "https://${cfg.serverName}";
server = "${cfg.serverName}:443";
};
};
};
};
})
(lib.mkIf (cfg.enable && config.youthlic.programs.caddy.enable) {
services.caddy.virtualHosts = {
"${cfg.serverName}" = {
extraConfig = ''
reverse_proxy 127.0.0.1:8481
'';
};
};
})
];
}

View file

@ -13,5 +13,6 @@
./steam.nix
./tailscale.nix
./transmission.nix
./conduwuit.nix
];
}