upgrade mastodon, needed to swap postgres ports as masto postgres does no longer allow for port control

This commit is contained in:
Cyryl Płotnicki 2023-05-08 12:03:29 +01:00
parent 8f33fb5ef4
commit 8a9b3e3763
5 changed files with 107 additions and 116 deletions

View file

@ -131,7 +131,7 @@
skinnyv = mkWorkstation nixpkgs-stable "x86_64-linux" "skinnyv"; skinnyv = mkWorkstation nixpkgs-stable "x86_64-linux" "skinnyv";
thinky = mkWorkstation nixpkgs-stable "x86_64-linux" "thinky"; thinky = mkWorkstation nixpkgs-stable "x86_64-linux" "thinky";
bolty = mkServer nixpkgs-stable "x86_64-linux" "bolty"; bolty = mkServer nixpkgs-stable "x86_64-linux" "bolty";
vpsfree1 = mkServer nixpkgs-stable "x86_64-linux" "vpsfree1"; vpsfree1 = mkServer nixpkgs-nixos-unstable "x86_64-linux" "vpsfree1";
mb1 = mkServer nixpkgs-stable "x86_64-linux" "mb1"; mb1 = mkServer nixpkgs-stable "x86_64-linux" "mb1";
yoga = mkKiosk nixpkgs-stable "x86_64-linux" "yoga"; yoga = mkKiosk nixpkgs-stable "x86_64-linux" "yoga";
homescreen = mkRaspi nixpkgs-stable "homescreen"; homescreen = mkRaspi nixpkgs-stable "homescreen";

View file

@ -8,7 +8,6 @@
./backups.nix ./backups.nix
./blog.cyplo.net.nix ./blog.cyplo.net.nix
./cryptpad.nix ./cryptpad.nix
./fossil.nix
./foundryvtt.nix ./foundryvtt.nix
./gitea.nix ./gitea.nix
./mastodon.nix ./mastodon.nix
@ -17,7 +16,6 @@
./search.nix ./search.nix
./ssh.nix ./ssh.nix
./syncthing-relay.nix ./syncthing-relay.nix
./woodpecker.nix
]; ];
systemd.extraConfig = '' systemd.extraConfig = ''

View file

@ -1,85 +1,71 @@
{ { config, pkgs, inputs, lib, ... }:
config, let
pkgs,
inputs,
lib,
...
}: let
port = 8081; port = 8081;
domain = "fossil.cyplo.dev"; domain = "fossil.cyplo.dev";
baseurl = "https://${domain}"; baseurl = "https://${domain}";
path = "/var/lib/fossil"; path = "/var/lib/fossil";
in { in {
imports = [../nginx.nix]; imports = [ ../nginx.nix ];
services.nginx = { services.nginx = {
virtualHosts = { virtualHosts = {
"${domain}" = { "${domain}" = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
locations."/" = {proxyPass = "http://localhost:" + toString port;}; locations."/" = { proxyPass = "http://localhost:" + toString port; };
}; };
}; };
}; };
containers.fossil = { containers.fossil = {
autoStart = true; autoStart = true;
forwardPorts = [ forwardPorts = [{
{ containerPort = port;
containerPort = port; hostPort = port;
hostPort = port; }];
}
];
bindMounts = { bindMounts = {
"${path}" = { "${path}" = {
hostPath = "${path}"; hostPath = "${path}";
isReadOnly = false; isReadOnly = false;
}; };
}; };
config = { config = { config, pkgs, ... }:
config, let
pkgs, user = "fossil";
... group = "fossil";
}: let in {
user = "fossil"; system.stateVersion = "22.11";
group = "fossil"; environment.systemPackages = [ pkgs.fossil ];
in { users.groups = { "${group}" = { }; };
system.stateVersion = "22.05"; users.users = {
environment.systemPackages = [pkgs.fossil]; fossil = {
users.groups = {"${group}" = {};}; inherit group;
users.users = { description = "Fossil Service";
fossil = { home = path;
inherit group; useDefaultShell = true;
description = "Fossil Service"; isSystemUser = true;
home = path; };
useDefaultShell = true; };
isSystemUser = true;
systemd.tmpfiles.rules = [ "d '${path}' 0770 ${user} ${group} - -" ];
systemd.services.fossil = {
description = "fossil server";
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.fossil pkgs.git ];
serviceConfig = {
User = user;
Group = group;
WorkingDirectory = path;
ReadWritePaths = [ path ];
ExecStart = "${pkgs.fossil}/bin/fossil server" + " --localhost"
+ " --https" + " --port ${toString port}"
+ " --baseurl ${baseurl}" + " --repolist ${path}";
Restart = "always";
RestartSec = 3;
};
}; };
}; };
systemd.tmpfiles.rules = ["d '${path}' 0770 ${user} ${group} - -"];
systemd.services.fossil = {
description = "fossil server";
after = ["network-online.target"];
wantedBy = ["multi-user.target"];
path = [pkgs.fossil pkgs.git];
serviceConfig = {
User = user;
Group = group;
WorkingDirectory = path;
ReadWritePaths = [path];
ExecStart =
"${pkgs.fossil}/bin/fossil server"
+ " --localhost"
+ " --https"
+ " --port ${toString port}"
+ " --baseurl ${baseurl}"
+ " --repolist ${path}";
Restart = "always";
RestartSec = 3;
};
};
};
}; };
} }

View file

@ -1,9 +1,11 @@
{ config, pkgs, inputs, lib, ... }: { config, pkgs, inputs, lib, ... }:
let let
unstablePkgs = inputs.nixpkgs-nixos-unstable.legacyPackages.${pkgs.system};
package = unstablePkgs.mastodon;
domain = "peninsula.industries"; domain = "peninsula.industries";
streamingPort = 55000; streamingPort = 55000;
webPort = 55001; webPort = 55001;
postgresPort = 5433; postgresPort = 5432;
path = "/var/lib/mastodon/"; path = "/var/lib/mastodon/";
mailgunSmtpSecretName = "mastodon-mailgun-smtp-password"; mailgunSmtpSecretName = "mastodon-mailgun-smtp-password";
mailgunSmtpPasswordPath = "/run/secrets/${mailgunSmtpSecretName}"; mailgunSmtpPasswordPath = "/run/secrets/${mailgunSmtpSecretName}";
@ -30,9 +32,9 @@ let
group = systemGroupName; group = systemGroupName;
}; };
publicPath = "${path}/public-system/"; publicPath = "${path}/public-system/";
package = inputs.nixpkgs-stable.legacyPackages."${pkgs.system}".mastodon;
in { in {
imports = [ ../nginx.nix ]; imports = [ ../nginx.nix ];
system.stateVersion = "22.11";
services.nginx = { services.nginx = {
virtualHosts = { virtualHosts = {
@ -109,18 +111,32 @@ in {
}; };
}; };
config = { config, pkgs, lib, ... }: { config = { config, pkgs, lib, ... }: {
system.stateVersion = "22.05"; system.stateVersion = "22.11";
services.postgresql.port = postgresPort; services.postgresql.port = postgresPort;
users = users // { users = users // {
mutableUsers = false; mutableUsers = false;
allowNoPasswordLogin = true; allowNoPasswordLogin = true;
}; };
systemd.services.mastodon-media-auto-remove = {
description = "Mastodon media auto remove";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = "/var/lib/mastodon/.secrets_env";
};
script = ''
/run/current-system/sw/bin/mastodon-tootctl media remove --days=8 --prune-profiles --include-follows -c1
/run/current-system/sw/bin/mastodon-tootctl media remove --days=8 --remove-headers --include-follows -c1
/run/current-system/sw/bin/mastodon-tootctl preview_cards remove --days=8
'';
startAt = "daily";
};
services.mastodon = { services.mastodon = {
enable = true; enable = true;
inherit package; inherit package;
localDomain = "${domain}"; localDomain = "${domain}";
user = systemUserName; user = systemUserName;
group = systemGroupName; group = systemGroupName;
mediaAutoRemove.enable = false;
smtp = { smtp = {
host = "smtp.eu.mailgun.org"; host = "smtp.eu.mailgun.org";
port = 465; port = 465;
@ -130,7 +146,7 @@ in {
createLocally = false; createLocally = false;
passwordFile = "${mailgunSmtpPasswordPath}"; passwordFile = "${mailgunSmtpPasswordPath}";
}; };
sidekiqThreads = 32; sidekiqThreads = 8;
extraConfig = { extraConfig = {
SMTP_TLS = "true"; SMTP_TLS = "true";
SMTP_ENABLE_STARTTLS_AUTO = "true"; SMTP_ENABLE_STARTTLS_AUTO = "true";

View file

@ -1,74 +1,65 @@
{ { config, pkgs, inputs, lib, ... }:
config, let
pkgs,
inputs,
lib,
...
}: let
port = 8080; port = 8080;
domain = "news.cyplo.dev"; domain = "news.cyplo.dev";
postgresPort = 5435;
in { in {
imports = [../nginx.nix]; imports = [ ../nginx.nix ];
services.nginx = { services.nginx = {
virtualHosts = { virtualHosts = {
"${domain}" = { "${domain}" = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
locations."/" = {proxyPass = "http://127.0.0.1:" + toString port;}; locations."/" = { proxyPass = "http://127.0.0.1:" + toString port; };
}; };
}; };
}; };
containers.rss = { containers.rss = {
autoStart = true; autoStart = true;
forwardPorts = [ forwardPorts = [{
{ containerPort = port;
containerPort = port; hostPort = port;
hostPort = port; }];
} config = { config, pkgs, ... }:
]; let
config = { inherit (config.services.tt-rss) pool;
config, inherit (config.services.tt-rss) root;
pkgs, in {
... system.stateVersion = "22.11";
}: let services.postgresql.port = postgresPort;
inherit (config.services.tt-rss) pool; services.tt-rss = {
inherit (config.services.tt-rss) root; enable = true;
in { selfUrlPath = "https://${domain}";
system.stateVersion = "22.05"; virtualHost = null;
services.tt-rss = { registration.enable = false;
enable = true; simpleUpdateMode = true;
selfUrlPath = "https://${domain}"; database.port = postgresPort;
virtualHost = null; };
registration.enable = false; services.nginx = {
simpleUpdateMode = true; enable = true;
}; virtualHosts = {
services.nginx = { "${domain}" = {
enable = true; listen = [{
virtualHosts = {
"${domain}" = {
listen = [
{
inherit port; inherit port;
addr = "0.0.0.0"; addr = "0.0.0.0";
} }];
]; root = "${root}/www";
root = "${root}/www"; locations."/" = { index = "index.php"; };
locations."/" = {index = "index.php";}; locations."^~ /feed-icons" = { root = "${root}"; };
locations."^~ /feed-icons" = {root = "${root}";}; locations."~ \\.php$" = {
locations."~ \\.php$" = { extraConfig = ''
extraConfig = '' fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:${
fastcgi_pass unix:${ config.services.phpfpm.pools.${pool}.socket
config.services.phpfpm.pools.${pool}.socket };
}; fastcgi_index index.php;
fastcgi_index index.php; '';
''; };
}; };
}; };
}; };
}; };
};
}; };
} }