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 =
8 file: cmd:
9 pkgs.runCommand file {
10 buildInputs = [ pkgs.openssl ];
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 =
40 { pkgs, ... }:
41 {
42 services.pantalaimon-headless.instances.${pantalaimonInstanceName} = {
43 homeserver = "https://localhost:8448";
44 listenAddress = "0.0.0.0";
45 listenPort = 8888;
46 logLevel = "debug";
47 ssl = false;
48 };
49
50 services.matrix-synapse = {
51 enable = true;
52 settings = {
53 listeners = [
54 {
55 port = 8448;
56 bind_addresses = [
57 "127.0.0.1"
58 "::1"
59 ];
60 type = "http";
61 tls = true;
62 x_forwarded = false;
63 resources = [
64 {
65 names = [
66 "client"
67 ];
68 compress = true;
69 }
70 {
71 names = [
72 "federation"
73 ];
74 compress = false;
75 }
76 ];
77 }
78 ];
79 database.name = "sqlite3";
80 tls_certificate_path = "${cert}";
81 tls_private_key_path = "${key}";
82 };
83 };
84 };
85
86 testScript = ''
87 start_all()
88 machine.wait_for_unit("pantalaimon-${pantalaimonInstanceName}.service")
89 machine.wait_for_unit("matrix-synapse.service")
90 machine.wait_until_succeeds(
91 "curl --fail -L http://localhost:8888/"
92 )
93 '';
94 }
95)