mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-24 01:23:24 +01:00
This avoids restarting the postgresql server, when only ensureDatabases or ensureUsers have been changed. It will also allow to properly wait for recovery to finish later. To wait for "postgresql is ready" in other services, we now provide a postgresql.target. Resolves #400018 Co-authored-by: Marcel <me@m4rc3l.de>
110 lines
2.6 KiB
Nix
110 lines
2.6 KiB
Nix
import ../../make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
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
|
|
mkdir -p $out
|
|
cp key.pem cert.pem $out
|
|
'';
|
|
|
|
hosts = ''
|
|
192.168.2.101 mastodon.local
|
|
'';
|
|
|
|
in
|
|
{
|
|
name = "mastodon-standard";
|
|
meta.maintainers = with pkgs.lib.maintainers; [
|
|
erictapen
|
|
izorkin
|
|
turion
|
|
];
|
|
|
|
nodes = {
|
|
server =
|
|
{ pkgs, ... }:
|
|
{
|
|
|
|
virtualisation.memorySize = 2048;
|
|
|
|
networking = {
|
|
interfaces.eth1 = {
|
|
ipv4.addresses = [
|
|
{
|
|
address = "192.168.2.101";
|
|
prefixLength = 24;
|
|
}
|
|
];
|
|
};
|
|
extraHosts = hosts;
|
|
firewall.allowedTCPPorts = [
|
|
80
|
|
443
|
|
];
|
|
};
|
|
|
|
security = {
|
|
pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
|
};
|
|
|
|
services.mastodon = {
|
|
enable = true;
|
|
configureNginx = true;
|
|
localDomain = "mastodon.local";
|
|
enableUnixSocket = false;
|
|
streamingProcesses = 2;
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
|
|
client =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = [ pkgs.jq ];
|
|
networking = {
|
|
interfaces.eth1 = {
|
|
ipv4.addresses = [
|
|
{
|
|
address = "192.168.2.102";
|
|
prefixLength = 24;
|
|
}
|
|
];
|
|
};
|
|
extraHosts = hosts;
|
|
};
|
|
|
|
security = {
|
|
pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
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.target")
|
|
server.wait_for_open_port(5432)
|
|
'';
|
|
};
|
|
}
|
|
)
|