1import ../make-test-python.nix (
2 { pkgs, ... }:
3 let
4 pantalaimonInstanceName = "testing";
5
6 # Set up SSL certs for Synapse to be happy.
7 runWithOpenSSL = file: cmd: pkgs.runCommand file
8 {
9 buildInputs = [ pkgs.openssl ];
10 }
11 cmd;
12
13 ca_key = runWithOpenSSL "ca-key.pem" "openssl genrsa -out $out 2048";
14 ca_pem = runWithOpenSSL "ca.pem" ''
15 openssl req \
16 -x509 -new -nodes -key ${ca_key} \
17 -days 10000 -out $out -subj "/CN=snakeoil-ca"
18 '';
19 key = runWithOpenSSL "matrix_key.pem" "openssl genrsa -out $out 2048";
20 csr = runWithOpenSSL "matrix.csr" ''
21 openssl req \
22 -new -key ${key} \
23 -out $out -subj "/CN=localhost" \
24 '';
25 cert = runWithOpenSSL "matrix_cert.pem" ''
26 openssl x509 \
27 -req -in ${csr} \
28 -CA ${ca_pem} -CAkey ${ca_key} \
29 -CAcreateserial -out $out \
30 -days 365
31 '';
32 in
33 {
34 name = "pantalaimon";
35 meta = with pkgs.lib; {
36 maintainers = teams.matrix.members;
37 };
38
39 nodes.machine = { pkgs, ... }: {
40 services.pantalaimon-headless.instances.${pantalaimonInstanceName} = {
41 homeserver = "https://localhost:8448";
42 listenAddress = "0.0.0.0";
43 listenPort = 8888;
44 logLevel = "debug";
45 ssl = false;
46 };
47
48 services.matrix-synapse = {
49 enable = true;
50 settings = {
51 listeners = [ {
52 port = 8448;
53 bind_addresses = [
54 "127.0.0.1"
55 "::1"
56 ];
57 type = "http";
58 tls = true;
59 x_forwarded = false;
60 resources = [ {
61 names = [
62 "client"
63 ];
64 compress = true;
65 } {
66 names = [
67 "federation"
68 ];
69 compress = false;
70 } ];
71 } ];
72 database.name = "sqlite3";
73 tls_certificate_path = "${cert}";
74 tls_private_key_path = "${key}";
75 };
76 };
77 };
78
79 testScript = ''
80 start_all()
81 machine.wait_for_unit("pantalaimon-${pantalaimonInstanceName}.service")
82 machine.wait_for_unit("matrix-synapse.service")
83 machine.wait_until_succeeds(
84 "curl --fail -L http://localhost:8888/"
85 )
86 '';
87 }
88)