2022-03-22 08:52:13 +01:00
|
|
|
import ../../make-test-python.nix ({pkgs, ...}:
|
2022-03-18 15:39:32 +01:00
|
|
|
let
|
2022-11-25 12:03:43 +01:00
|
|
|
cert = pkgs: pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
|
|
|
|
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=mastodon.local' -days 36500
|
2022-03-18 15:39:32 +01:00
|
|
|
mkdir -p $out
|
2022-11-25 12:03:43 +01:00
|
|
|
cp key.pem cert.pem $out
|
2022-03-18 15:39:32 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
hosts = ''
|
2022-11-25 12:48:48 +01:00
|
|
|
192.168.2.101 mastodon.local
|
2022-03-18 15:39:32 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
2022-03-22 08:52:13 +01:00
|
|
|
name = "mastodon-standard";
|
2022-11-17 19:29:36 +01:00
|
|
|
meta.maintainers = with pkgs.lib.maintainers; [ erictapen izorkin turion ];
|
2022-03-18 15:39:32 +01:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
server = { pkgs, ... }: {
|
2022-11-06 19:53:30 +01:00
|
|
|
|
|
|
|
virtualisation.memorySize = 2048;
|
|
|
|
|
2022-03-18 15:39:32 +01:00
|
|
|
networking = {
|
|
|
|
interfaces.eth1 = {
|
|
|
|
ipv4.addresses = [
|
2022-11-25 12:48:48 +01:00
|
|
|
{ address = "192.168.2.101"; prefixLength = 24; }
|
2022-03-18 15:39:32 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
extraHosts = hosts;
|
|
|
|
firewall.allowedTCPPorts = [ 80 443 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
security = {
|
2022-11-25 12:03:43 +01:00
|
|
|
pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
2022-03-18 15:39:32 +01:00
|
|
|
};
|
|
|
|
|
2023-11-13 15:23:49 +01:00
|
|
|
# TODO remove once https://github.com/NixOS/nixpkgs/pull/266270 is resolved.
|
|
|
|
services.postgresql.package = pkgs.postgresql_14;
|
|
|
|
|
2022-03-18 15:39:32 +01:00
|
|
|
services.mastodon = {
|
|
|
|
enable = true;
|
|
|
|
configureNginx = true;
|
|
|
|
localDomain = "mastodon.local";
|
|
|
|
enableUnixSocket = false;
|
2023-08-23 16:26:32 +02:00
|
|
|
streamingProcesses = 2;
|
2022-03-18 15:39:32 +01:00
|
|
|
smtp = {
|
|
|
|
createLocally = false;
|
|
|
|
fromAddress = "mastodon@mastodon.local";
|
|
|
|
};
|
|
|
|
extraConfig = {
|
|
|
|
EMAIL_DOMAIN_ALLOWLIST = "example.com";
|
|
|
|
};
|
|
|
|
};
|
2022-11-25 12:03:43 +01:00
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
virtualHosts."mastodon.local" = {
|
|
|
|
enableACME = pkgs.lib.mkForce false;
|
|
|
|
sslCertificate = "${cert pkgs}/cert.pem";
|
|
|
|
sslCertificateKey = "${cert pkgs}/key.pem";
|
|
|
|
};
|
|
|
|
};
|
2022-03-18 15:39:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
client = { pkgs, ... }: {
|
|
|
|
environment.systemPackages = [ pkgs.jq ];
|
|
|
|
networking = {
|
|
|
|
interfaces.eth1 = {
|
|
|
|
ipv4.addresses = [
|
2022-11-25 12:48:48 +01:00
|
|
|
{ address = "192.168.2.102"; prefixLength = 24; }
|
2022-03-18 15:39:32 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
extraHosts = hosts;
|
|
|
|
};
|
|
|
|
|
|
|
|
security = {
|
2022-11-25 12:03:43 +01:00
|
|
|
pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
2022-03-18 15:39:32 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-25 14:55:08 +01:00
|
|
|
testScript = import ./script.nix {
|
|
|
|
inherit pkgs;
|
|
|
|
extraInit = ''
|
|
|
|
server.wait_for_unit("nginx.service")
|
|
|
|
server.wait_for_open_port(443)
|
2024-02-16 19:29:30 +01:00
|
|
|
server.wait_for_unit("redis-mastodon.service")
|
2022-11-25 14:55:08 +01:00
|
|
|
server.wait_for_unit("postgresql.service")
|
|
|
|
server.wait_for_open_port(5432)
|
|
|
|
'';
|
|
|
|
};
|
2022-03-18 15:39:32 +01:00
|
|
|
})
|