summaryrefslogtreecommitdiffstats
path: root/system/services/mastodon
diff options
context:
space:
mode:
authorsils <sils@sils.li>2023-10-14 15:28:05 +0200
committersils <sils@sils.li>2023-10-14 15:28:05 +0200
commit04e4866a17853d583c943b52ec2b9c5e7518e4ae (patch)
treebd079002dbebd4fffc533596c3f4e5a99a6b3a56 /system/services/mastodon
parentFix(system/services/etebase): Add proxy parameters (diff)
parentfix(system/services/mastodon): Correctly avoid string casts (diff)
downloadnixos-server-04e4866a17853d583c943b52ec2b9c5e7518e4ae.zip
Merge branch 'main' into etebase
Diffstat (limited to 'system/services/mastodon')
-rw-r--r--system/services/mastodon/default.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/system/services/mastodon/default.nix b/system/services/mastodon/default.nix
new file mode 100644
index 0000000..39a0f56
--- /dev/null
+++ b/system/services/mastodon/default.nix
@@ -0,0 +1,54 @@
+{config, ...}: let
+ emailAddress = "mastodon@vhack.eu";
+in {
+ services.mastodon = {
+ enable = true;
+ localDomain = "vhack.eu";
+ smtp = {
+ authenticate = true;
+ createLocally = false;
+ fromAddress = emailAddress;
+ user = emailAddress;
+ host = "server1.vhack.eu";
+ passwordFile = config.age.secrets.mastodonMail.path;
+ };
+ extraConfig = {
+ WEB_DOMAIN = "mastodon.vhack.eu";
+ EMAIL_DOMAIN_ALLOWLIST = "vhack.eu|sils.li";
+ };
+ };
+
+ services.nginx = {
+ enable = true;
+ recommendedProxySettings = true; # required for redirections to work
+ virtualHosts = {
+ ${config.services.mastodon.extraConfig.WEB_DOMAIN} = {
+ root = "${config.services.mastodon.package}/public/";
+ # mastodon only supports https, but you can override this if you offload tls elsewhere.
+ forceSSL = true;
+ enableACME = true;
+
+ locations = {
+ "/system/".alias = "/var/lib/mastodon/public-system/";
+ "/".tryFiles = "$uri @proxy";
+ "@proxy" = {
+ proxyPass = "http://unix:/run/mastodon-web/web.socket";
+ proxyWebsockets = true;
+ };
+ "/api/v1/streaming/" = {
+ proxyPass = "http://unix:/run/mastodon-streaming/streaming.socket";
+ proxyWebsockets = true;
+ };
+ };
+ };
+
+ "vhack.eu" = {
+ locations."/.well-known/webfinger".return = "301 https://${config.services.mastodon.extraConfig.WEB_DOMAIN}$request_uri";
+ };
+ };
+ };
+
+ users.groups.${config.services.mastodon.group}.members = [
+ config.services.nginx.user
+ ];
+}