2023-11-05 22:47:06 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
flake,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
2023-10-28 14:45:30 +00:00
|
|
|
{
|
|
|
|
age.secrets."mastodon-secret-key-base" = {
|
|
|
|
file = "${flake.self}/secrets/mastodon-secret-key-base.age";
|
|
|
|
mode = "400";
|
|
|
|
owner = config.services.mastodon.user;
|
|
|
|
};
|
|
|
|
age.secrets."mastodon-otp-secret" = {
|
|
|
|
file = "${flake.self}/secrets/mastodon-otp-secret.age";
|
|
|
|
mode = "400";
|
|
|
|
owner = config.services.mastodon.user;
|
|
|
|
};
|
|
|
|
age.secrets."mastodon-vapid-private-key" = {
|
|
|
|
file = "${flake.self}/secrets/mastodon-vapid-private-key.age";
|
|
|
|
mode = "400";
|
|
|
|
owner = config.services.mastodon.user;
|
|
|
|
};
|
|
|
|
age.secrets."mastodon-vapid-public-key" = {
|
|
|
|
file = "${flake.self}/secrets/mastodon-vapid-public-key.age";
|
|
|
|
mode = "400";
|
|
|
|
owner = config.services.mastodon.user;
|
|
|
|
};
|
|
|
|
age.secrets."mastodon-smtp-password" = {
|
|
|
|
file = "${flake.self}/secrets/mastodon-smtp-password.age";
|
|
|
|
mode = "400";
|
|
|
|
owner = config.services.mastodon.user;
|
|
|
|
};
|
|
|
|
age.secrets."mastodon-extra-env-secrets" = {
|
|
|
|
file = "${flake.self}/secrets/mastodon-extra-env-secrets.age";
|
|
|
|
mode = "400";
|
|
|
|
owner = config.services.mastodon.user;
|
|
|
|
};
|
|
|
|
|
2023-10-29 01:38:46 +00:00
|
|
|
# Nginx user needs access to mastodon unix sockets
|
|
|
|
users.users.nginx.extraGroups = [ "mastodon" ];
|
|
|
|
|
2023-10-28 14:45:30 +00:00
|
|
|
services.mastodon = {
|
|
|
|
enable = true;
|
|
|
|
# Different from WEB_DOMAIN in our case
|
2024-05-08 17:47:47 +00:00
|
|
|
localDomain = "${config.pub-solar-os.networking.domain}";
|
2023-10-28 14:45:30 +00:00
|
|
|
enableUnixSocket = true;
|
2023-11-18 17:46:23 +00:00
|
|
|
# Number of processes used by the mastodon-streaming service
|
|
|
|
# Recommended is the amount of your CPU cores minus one
|
|
|
|
# On our current 8-Core system, let's start with 5 for now
|
2023-10-28 16:18:06 +00:00
|
|
|
streamingProcesses = 5;
|
2023-10-28 14:45:30 +00:00
|
|
|
# Processes used by the mastodon-web service
|
|
|
|
webProcesses = 2;
|
|
|
|
# Threads per process used by the mastodon-web service
|
|
|
|
webThreads = 5;
|
|
|
|
secretKeyBaseFile = "/run/agenix/mastodon-secret-key-base";
|
|
|
|
otpSecretFile = "/run/agenix/mastodon-otp-secret";
|
|
|
|
vapidPrivateKeyFile = "/run/agenix/mastodon-vapid-private-key";
|
|
|
|
vapidPublicKeyFile = "/run/agenix/mastodon-vapid-public-key";
|
|
|
|
smtp = {
|
|
|
|
createLocally = false;
|
2023-12-05 17:23:04 +00:00
|
|
|
host = "mail.greenbaum.zone";
|
2023-10-28 14:45:30 +00:00
|
|
|
port = 587;
|
|
|
|
authenticate = true;
|
|
|
|
user = "admins@pub.solar";
|
|
|
|
passwordFile = "/run/agenix/mastodon-smtp-password";
|
|
|
|
fromAddress = "mastodon-notifications@pub.solar";
|
|
|
|
};
|
2024-04-05 21:50:04 +00:00
|
|
|
mediaAutoRemove = {
|
|
|
|
olderThanDays = 7;
|
|
|
|
};
|
2023-10-28 14:45:30 +00:00
|
|
|
extraEnvFiles = [ "/run/agenix/mastodon-extra-env-secrets" ];
|
|
|
|
extraConfig = {
|
2024-05-08 17:47:47 +00:00
|
|
|
WEB_DOMAIN = "mastodon.${config.pub-solar-os.networking.domain}";
|
2023-10-28 16:18:06 +00:00
|
|
|
# Defined in ./opensearch.nix
|
2023-10-28 14:45:30 +00:00
|
|
|
ES_HOST = "127.0.0.1";
|
|
|
|
# S3 File storage (optional)
|
|
|
|
# -----------------------
|
|
|
|
S3_ENABLED = "true";
|
|
|
|
S3_BUCKET = "pub-solar-mastodon";
|
|
|
|
S3_REGION = "europe-west-1";
|
|
|
|
S3_ENDPOINT = "https://gateway.tardigradeshare.io";
|
2024-05-08 17:47:47 +00:00
|
|
|
S3_ALIAS_HOST = "files.${config.pub-solar-os.networking.domain}";
|
2023-10-28 14:45:30 +00:00
|
|
|
# Translation (optional)
|
|
|
|
# -----------------------
|
|
|
|
DEEPL_PLAN = "free";
|
|
|
|
# OpenID Connect
|
|
|
|
# --------------
|
|
|
|
OIDC_ENABLED = "true";
|
|
|
|
OIDC_DISPLAY_NAME = "pub.solar ID";
|
2024-05-08 17:47:47 +00:00
|
|
|
OIDC_ISSUER = "https://auth.${config.pub-solar-os.networking.domain}/realms/${config.pub-solar-os.auth.realm}";
|
2023-10-28 14:45:30 +00:00
|
|
|
OIDC_DISCOVERY = "true";
|
|
|
|
OIDC_SCOPE = "openid,profile,email";
|
|
|
|
OIDC_UID_FIELD = "preferred_username";
|
2024-05-08 17:47:47 +00:00
|
|
|
OIDC_REDIRECT_URI = "https://mastodon.${config.pub-solar-os.networking.domain}/auth/auth/openid_connect/callback";
|
2023-10-28 14:45:30 +00:00
|
|
|
OIDC_SECURITY_ASSUME_EMAIL_IS_VERIFIED = "true";
|
|
|
|
# only use OIDC for login / registration
|
|
|
|
OMNIAUTH_ONLY = "true";
|
|
|
|
};
|
|
|
|
};
|
2023-11-05 21:54:09 +00:00
|
|
|
|
2023-11-18 21:28:12 +00:00
|
|
|
services.restic.backups.mastodon-droppie = {
|
2023-11-05 21:54:09 +00:00
|
|
|
paths = [ "/tmp/mastodon-backup.sql" ];
|
2023-11-05 22:47:06 +00:00
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
|
|
|
|
# droppie will be offline if nachtigall misses the timer
|
|
|
|
Persistent = false;
|
|
|
|
};
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-repo-droppie".path;
|
2023-11-06 21:58:48 +00:00
|
|
|
repository = "sftp:yule@droppie.b12f.io:/media/internal/pub.solar";
|
2023-11-05 21:54:09 +00:00
|
|
|
backupPrepareCommand = ''
|
2023-11-06 21:22:36 +00:00
|
|
|
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d mastodon > /tmp/mastodon-backup.sql
|
2023-11-05 21:54:09 +00:00
|
|
|
'';
|
|
|
|
backupCleanupCommand = ''
|
|
|
|
rm /tmp/mastodon-backup.sql
|
|
|
|
'';
|
2024-04-22 18:06:49 +00:00
|
|
|
pruneOpts = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 4"
|
|
|
|
"--keep-monthly 3"
|
|
|
|
];
|
2023-11-05 21:54:09 +00:00
|
|
|
};
|
2023-11-18 21:28:12 +00:00
|
|
|
|
|
|
|
services.restic.backups.mastodon-storagebox = {
|
|
|
|
paths = [ "/tmp/mastodon-backup.sql" ];
|
|
|
|
timerConfig = {
|
2024-05-15 19:00:41 +00:00
|
|
|
OnCalendar = "*-*-* 04:00:00 Etc/UTC";
|
2023-11-18 21:28:12 +00:00
|
|
|
};
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-repo-storagebox".path;
|
|
|
|
repository = "sftp:u377325@u377325.your-storagebox.de:/backups";
|
|
|
|
backupPrepareCommand = ''
|
|
|
|
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d mastodon > /tmp/mastodon-backup.sql
|
|
|
|
'';
|
|
|
|
backupCleanupCommand = ''
|
|
|
|
rm /tmp/mastodon-backup.sql
|
|
|
|
'';
|
2024-04-22 18:06:49 +00:00
|
|
|
pruneOpts = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 4"
|
|
|
|
"--keep-monthly 3"
|
|
|
|
];
|
2023-11-18 21:28:12 +00:00
|
|
|
};
|
2023-10-28 14:45:30 +00:00
|
|
|
}
|