aboutsummaryrefslogtreecommitdiff
path: root/modules/services/akkoma/default.nix
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2023-03-29 20:54:19 +0900
committersefidel <contact@sefidel.net>2023-04-03 18:32:29 +0900
commitce06f43476863da90dc60dcee606d2b6c5a89a8e (patch)
tree5d14946330cb09ff0ebd97bee59407fccee4d860 /modules/services/akkoma/default.nix
downloadinfra-ce06f43476863da90dc60dcee606d2b6c5a89a8e.zip
project: initial commit
Diffstat (limited to 'modules/services/akkoma/default.nix')
-rw-r--r--modules/services/akkoma/default.nix95
1 files changed, 95 insertions, 0 deletions
diff --git a/modules/services/akkoma/default.nix b/modules/services/akkoma/default.nix
new file mode 100644
index 0000000..a0cd42c
--- /dev/null
+++ b/modules/services/akkoma/default.nix
@@ -0,0 +1,95 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ cfg = config.modules.services.akkoma;
+
+ poorObfuscation = y: x: "${x}@${y}";
+ federation-blocklist = lib.importTOML ./blocklist.toml;
+
+ inherit (lib.my) wrapFile;
+in
+{
+ options.modules.services.akkoma = {
+ enable = mkEnableOption "Akkoma instance";
+ domain = mkOption { type = types.str; };
+ realHost = mkOption { type = types.str; };
+ instanceName = mkOption { type = types.str; default = "Akkoma on ${cfg.domain}"; };
+ };
+
+ config = mkIf cfg.enable {
+ modules.services.postgresql.enable = true;
+
+ services.akkoma = {
+ enable = true;
+ initDb.enable = true;
+
+ extraStatic = {
+ "static/terms-of-service.html" = wrapFile "terms-of-service.html" ./terms-of-service.html;
+ "static/logo.svg" = wrapFile "logo.svg" ./logo.svg;
+ "static/logo.png" = wrapFile "logo.png" ./logo.png;
+ "static/logo-512.png" = wrapFile "logo-512.png" ./favicon-withbg.png; # Intentional, for PWA favicon.
+ "static/icon.png" = wrapFile "icon.png" ./favicon.png;
+ "favicon.png" = wrapFile "favicon.png" ./favicon.png;
+ };
+ config =
+ let inherit ((pkgs.formats.elixirConf { }).lib) mkRaw mkMap;
+ in {
+ ":pleroma"."Pleroma.Web.Endpoint".url.host = cfg.realHost;
+ ":pleroma"."Pleroma.Web.WebFinger".domain = cfg.domain;
+ ":pleroma".":media_proxy".enabled = false;
+ ":pleroma".":instance" = {
+ name = cfg.instanceName;
+
+ description = "Private akkoma instance";
+ email = poorObfuscation cfg.domain "postmaster";
+ notify_email = poorObfuscation cfg.domain "postmaster";
+
+ registrations_open = false;
+ invites_enabled = true;
+
+ limit = 5000;
+ };
+ ":pleroma".":frontend_configurations" = {
+ pleroma_fe = mkMap {
+ logo = "/static/logo.png";
+ };
+ };
+ ":pleroma".":mrf" = {
+ policies = map mkRaw [ "Pleroma.Web.ActivityPub.MRF.SimplePolicy" ];
+ };
+ ":pleroma".":mrf_simple" = {
+ followers_only = mkMap federation-blocklist.followers_only;
+ media_nsfw = mkMap federation-blocklist.media_nsfw;
+ reject = mkMap federation-blocklist.reject;
+ };
+ };
+
+ nginx = {
+ forceSSL = true;
+ useACMEHost = cfg.domain;
+
+ locations."~ \\.(js|css|woff|woff2?|png|jpe?g|svg)$" = {
+ extraConfig = ''
+ add_header Cache-Control "public, max-age=14400, must-revalidate";
+ '';
+
+ proxyPass = "http://unix:${config.services.akkoma.config.":pleroma"."Pleroma.Web.Endpoint".http.ip}";
+ proxyWebsockets = true;
+ recommendedProxySettings = true;
+ };
+ };
+ };
+
+ services.nginx.virtualHosts.${cfg.domain} = {
+ forceSSL = true;
+ useACMEHost = cfg.domain;
+
+ locations."/.well-known/host-meta" = {
+ extraConfig = ''
+ return 301 https://${cfg.realHost}$request_uri;
+ '';
+ };
+ };
+ };
+ }