nixpkgs-suyu/nixos/tests/web-apps/mastodon/standard.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2.3 KiB
Nix
Raw Permalink Normal View History

import ../../make-test-python.nix ({pkgs, ...}:
2022-03-18 15:39:32 +01:00
let
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
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
{
name = "mastodon-standard";
meta.maintainers = with pkgs.lib.maintainers; [ erictapen izorkin turion ];
2022-03-18 15:39:32 +01:00
nodes = {
server = { pkgs, ... }: {
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 = {
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;
streamingProcesses = 2;
2022-03-18 15:39:32 +01:00
smtp = {
createLocally = false;
fromAddress = "mastodon@mastodon.local";
};
extraConfig = {
EMAIL_DOMAIN_ALLOWLIST = "example.com";
};
};
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 = {
pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
2022-03-18 15:39:32 +01:00
};
};
};
testScript = import ./script.nix {
inherit pkgs;
extraInit = ''
server.wait_for_unit("nginx.service")
server.wait_for_open_port(443)
server.wait_for_unit("redis-mastodon.service")
server.wait_for_unit("postgresql.service")
server.wait_for_open_port(5432)
'';
};
2022-03-18 15:39:32 +01:00
})