Add mastodon (work in progress)

This commit is contained in:
Oliver Davies 2025-05-09 22:15:02 +01:00
parent d30cba946f
commit 55f57ddd26
2 changed files with 85 additions and 0 deletions

View file

@ -8,6 +8,7 @@
{
imports = [
./homepage
./mastodon.nix
./samba.nix
./uptime-kuma.nix
./vaultwarden.nix

View file

@ -0,0 +1,84 @@
{ config, lib, ... }:
with lib;
let
cfg = config.homelab.services.${service};
domain = "oliverdavies.uk";
service = "mastodon";
in
{
options.homelab.services.${service} = {
url = mkOption {
default = "social.${domain}";
internal = true;
type = types.str;
};
};
config = {
services = {
${service} = {
enable = false;
configureNginx = false;
localDomain = domain;
streamingProcesses = 3;
extraConfig = {
SINGLE_USER_MODE = "true";
WEB_DOMAIN = cfg.url;
};
smtp = {
fromAddress = "social@${domain}";
};
};
cloudflared.tunnels.${config.homelab.cloudflared.tunnelId} = {
ingress = {
"${cfg.url}" = "http://localhost";
};
};
nginx = {
upstreams.mastodon-streaming = {
extraConfig = ''
least_conn;
'';
servers = builtins.listToAttrs (
map (i: {
name = "unix:/run/mastodon-streaming/streaming-${toString i}.socket";
value = { };
}) (range 1 config.services.mastodon.streamingProcesses)
);
};
virtualHosts."social.oliverdavies.uk" = {
root = "${config.services.mastodon.package}/public/";
locations = {
"/".tryFiles = "$uri @proxy";
"/api/v1/streaming/" = {
proxyPass = "http://mastodon-streaming";
proxyWebsockets = true;
};
"/system/".alias = "/var/lib/mastodon/public-system/";
"@proxy" = {
proxyPass = "http://unix:/run/mastodon-web/web.socket";
proxyWebsockets = true;
};
};
extraConfig = ''
client_max_body_size 100m;
'';
};
};
};
};
}