nixos/modules/server/fedi/akkoma/default.nix

190 lines
6 KiB
Nix
Raw Normal View History

2025-01-02 14:49:22 +04:00
{ config, lib, pkgs, ... }:
2025-01-02 12:27:19 +04:00
with lib;
2025-01-02 17:37:31 +04:00
let
cfg = config.void.server.fedi.akkoma;
inherit ((pkgs.formats.elixirConf { }).lib) mkRaw mkMap;
2025-01-02 12:27:19 +04:00
in {
options.void.server.fedi.akkoma = { enable = mkEnableOption false; };
# :(
config = mkIf cfg.enable {
2025-01-02 14:47:50 +04:00
security.acme.certs = {
2025-01-03 19:53:08 +04:00
"fedi.sako.lol" = {
2025-01-02 14:58:47 +04:00
credentialsFile = "/srv/secrets/porkbun";
dnsProvider = "porkbun";
webroot = null;
};
2025-01-03 19:53:08 +04:00
"media.fedi.sako.lol" = {
2025-01-02 14:58:47 +04:00
credentialsFile = "/srv/secrets/porkbun";
dnsProvider = "porkbun";
webroot = null;
};
2025-01-02 14:47:50 +04:00
};
2025-01-02 12:27:19 +04:00
services = {
akkoma = {
enable = true;
package = pkgs.akkoma;
2025-01-02 20:44:06 +04:00
extraStatic = {
"emoji/blobs.gg" = pkgs.akkoma-emoji.blobs_gg;
2025-01-04 22:22:32 +04:00
# TODO Change this lmao
"static/favicon.png" = pkgs.fetchurl {
url = "https://sako.lol/icon.png";
hash = "sha256-G8qYTlRwQWn+x6b9t0gFBriIxm6LV2n1jI5OcTSg/jc=";
};
2025-01-02 20:46:30 +04:00
"static/terms-of-service.html" =
pkgs.writeText "terms-of-service.html" ''
<h1>Rules</h1>
<ol>
<li>No NSFW <b><i>at all</i></b></li>
<li>try not to get this server blacklisted thanks :)</li>
</ol>
2025-01-02 20:44:06 +04:00
2025-01-02 20:46:30 +04:00
Instance is invite only because I don't know how many users this will handle, if you know any contact methods for the admin go ask him for an invite.
'';
# "favicon.png" = let
# rev = "697a8211b0f427a921e7935a35d14bb3e32d0a2c";
# in pkgs.stdenvNoCC.mkDerivation {
# name = "favicon.png";
2025-01-02 20:44:06 +04:00
2025-01-02 20:46:30 +04:00
# src = pkgs.fetchurl {
# url = "https://raw.githubusercontent.com/TilCreator/NixOwO/${rev}/NixOwO_plain.svg";
# hash = "sha256-tWhHMfJ3Od58N9H5yOKPMfM56hYWSOnr/TGCBi8bo9E=";
# };
2025-01-02 20:44:06 +04:00
2025-01-02 20:46:30 +04:00
# nativeBuildInputs = with pkgs; [ librsvg ];
2025-01-02 20:44:06 +04:00
2025-01-02 20:46:30 +04:00
# dontUnpack = true;
# installPhase = ''
# rsvg-convert -o $out -w 96 -h 96 $src
# '';
};
2025-01-02 15:53:53 +04:00
extraPackages =
builtins.attrValues { inherit (pkgs) ffmpeg exiftool imagemagick; };
2025-01-02 14:47:50 +04:00
frontends = {
primary = {
package = pkgs.akkoma-frontends.akkoma-fe;
name = "akkoma-fe";
ref = "stable";
};
admin = {
package = pkgs.akkoma-frontends.admin-fe;
name = "admin-fe";
ref = "stable";
};
};
nginx = {
enableACME = true;
forceSSL = true;
2025-01-02 14:48:49 +04:00
# recommendedTlsSettings = true;
# recommendedOptimisation = true;
# recommendedGzipSettings = true;
2025-01-02 14:47:50 +04:00
};
config = {
":pleroma" = {
":instance" = {
name = "v0id";
description = "Good ass fediverse instance";
email = "sako@sako.lol";
registration_open = false;
invites_enabled = true;
account_activation_required = false;
cleanup_attachments = true;
allow_relay = true;
2025-01-02 17:20:28 +04:00
# AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
federating = true;
2025-01-03 19:33:11 +04:00
# external_user_synchronization = true;
2025-01-02 14:47:50 +04:00
};
2025-01-02 15:34:20 +04:00
":media_proxy" = {
2025-01-02 16:12:34 +04:00
enabled = true;
proxy_opts = { redirect_on_failure = true; };
2025-01-03 19:53:08 +04:00
base_url = "https://media.fedi.sako.lol";
2025-01-02 15:34:20 +04:00
};
2025-01-03 19:53:08 +04:00
"Pleroma.Web.Endpoint" = { url.host = "fedi.sako.lol"; };
2025-01-02 14:47:50 +04:00
"Pleroma.Upload" = {
2025-01-03 19:53:08 +04:00
base_url = "https://media.fedi.sako.lol/media";
2025-01-02 14:47:50 +04:00
filters = map (pkgs.formats.elixirConf { }).lib.mkRaw [
2025-01-02 15:00:09 +04:00
"Pleroma.Upload.Filter.Exiftool.StripMetadata"
2025-01-02 14:47:50 +04:00
"Pleroma.Upload.Filter.Dedupe"
"Pleroma.Upload.Filter.AnonymizeFilename"
];
};
2025-01-02 17:43:11 +04:00
":mrf".policies =
map mkRaw [ "Pleroma.Web.ActivityPub.MRF.SimplePolicy" ];
2025-01-02 17:35:33 +04:00
":mrf_simple" = let blocklist = import ./blocklist.nix;
in {
# media_nsfw = mkMap blocklist.media_nsfw;
2025-01-02 17:37:31 +04:00
reject = mkMap blocklist.reject;
2025-01-02 17:35:33 +04:00
# followers_only = mkMap blocklist.followers_only;
};
2025-01-02 14:47:50 +04:00
};
};
2025-01-02 12:27:19 +04:00
};
2025-01-02 16:12:34 +04:00
nginx.proxyCachePath."akkoma-media-cache" = {
enable = true;
levels = "1:2";
inactive = "720m";
maxSize = "10g";
useTempPath = false;
keysZoneName = "akkoma_media_cache";
keysZoneSize = "10m";
};
2025-01-02 15:53:53 +04:00
nginx.virtualHosts = {
2025-01-03 19:53:08 +04:00
"media.fedi.sako.lol" = {
2025-01-02 15:53:53 +04:00
forceSSL = true;
enableACME = true;
2025-01-02 16:12:34 +04:00
locations = {
2025-01-03 19:53:08 +04:00
"/" = { return = "301 https://fedi.sako.lol"; };
2025-01-02 16:12:34 +04:00
"/media" = { proxyPass = "http://unix:/run/akkoma/socket"; };
2025-01-02 16:32:53 +04:00
"/proxy" = {
proxyPass = "http://unix:/run/akkoma/socket";
extraConfig = ''
proxy_cache akkoma_media_cache;
proxy_cache_lock on;
'';
};
2025-01-02 16:12:34 +04:00
};
2025-01-02 15:53:53 +04:00
};
};
2025-01-02 12:27:19 +04:00
};
2025-01-03 21:01:02 +04:00
# can't have SHIT in detroit
users = {
2025-01-03 21:01:23 +04:00
users.fedifetcher = {
2025-01-03 21:01:02 +04:00
home = "/var/lib/fedifetcher";
createHome = true;
isSystemUser = true;
group = "fedifetcher";
};
groups.fedifetcher = { };
};
systemd = let
configPath = "/srv/secrets/fedifetcher.json";
state = "/var/lib/fedifetcher";
in {
timers.fedifetcher = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnUnitActiveSec = "1m";
Unit = "fedifetcher.service";
};
};
services.fedifetcher = {
unitConfig = { ConditionPathExists = configPath; };
serviceConfig = {
WorkingDirectory = state;
Type = "oneshot";
2025-01-03 21:03:10 +04:00
ExecStart = "${pkgs.fedifetcher}/bin/fedifetcher"
2025-01-03 21:01:02 +04:00
+ " --config ${configPath}" + " --state-dir ${state}";
2025-01-03 21:04:39 +04:00
User = "fedifetcher";
Group = "fedifetcher";
2025-01-03 21:01:02 +04:00
};
};
};
2025-01-02 12:27:19 +04:00
};
}