1 import ../../make-test-python.nix (
6 pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
7 openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=mastodon.local' -days 36500
9 cp key.pem cert.pem $out
13 192.168.2.103 mastodon.local
16 postgresqlPassword = "thisisnotasecret";
17 redisPassword = "thisisnotasecrettoo";
21 name = "mastodon-remote-postgresql";
22 meta.maintainers = with pkgs.lib.maintainers; [
33 "redis/password-redis-db".text = redisPassword;
40 address = "192.168.2.102";
46 firewall.allowedTCPPorts = [
47 config.services.redis.servers.mastodon.port
48 config.services.postgresql.settings.port
52 services.redis.servers.mastodon = {
56 requirePassFile = "/etc/redis/password-redis-db";
59 services.postgresql = {
63 hostnossl mastodon mastodon 192.168.2.201/32 md5
65 ensureDatabases = [ "mastodon" ];
69 ensureDBOwnership = true;
72 initialScript = pkgs.writeText "postgresql_init.sql" ''
73 CREATE ROLE mastodon LOGIN PASSWORD '${postgresqlPassword}';
85 address = "192.168.2.103";
91 firewall.allowedTCPPorts = [
98 pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
103 recommendedProxySettings = true;
104 virtualHosts."mastodon.local" = {
107 enableACME = pkgs.lib.mkForce false;
108 sslCertificate = "${cert pkgs}/cert.pem";
109 sslCertificateKey = "${cert pkgs}/key.pem";
111 tryFiles = "$uri @proxy";
113 locations."@proxy" = {
114 proxyPass = "http://192.168.2.201:${toString nodes.server.services.mastodon.webPort}";
115 proxyWebsockets = true;
122 { config, pkgs, ... }:
124 virtualisation.memorySize = 2048;
128 "mastodon/password-redis-db".text = redisPassword;
129 "mastodon/password-posgressql-db".text = postgresqlPassword;
137 address = "192.168.2.201";
143 firewall.allowedTCPPorts = [
144 config.services.mastodon.webPort
145 config.services.mastodon.sidekiqPort
149 services.mastodon = {
151 configureNginx = false;
152 localDomain = "mastodon.local";
153 enableUnixSocket = false;
154 streamingProcesses = 2;
156 createLocally = false;
157 host = "192.168.2.102";
159 passwordFile = "/etc/mastodon/password-redis-db";
162 createLocally = false;
163 host = "192.168.2.102";
167 passwordFile = "/etc/mastodon/password-posgressql-db";
170 createLocally = false;
171 fromAddress = "mastodon@mastodon.local";
175 EMAIL_DOMAIN_ALLOWLIST = "example.com";
176 RAILS_SERVE_STATIC_FILES = "true";
177 TRUSTED_PROXY_IP = "192.168.2.103";
185 environment.systemPackages = [ pkgs.jq ];
190 address = "192.168.2.202";
199 pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
204 testScript = import ./script.nix {
207 nginx.wait_for_unit("nginx.service")
208 nginx.wait_for_open_port(443)
209 databases.wait_for_unit("redis-mastodon.service")
210 databases.wait_for_unit("postgresql.service")
211 databases.wait_for_open_port(31637)
212 databases.wait_for_open_port(5432)