blob: d7ba8b6951a2f18f72a165af6bb0f1ace85b292d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
{
config,
pkgs,
lib,
...
}:
# NOTE: most of this is taken from the prosody test
let
cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 365 \
-subj '/C=GB/CN=example.com/CN=uploads.example.com/CN=conference.example.com' -addext "subjectAltName = DNS:example.com,DNS:uploads.example.com,DNS:conference.example.com"
mkdir -p $out
cp key.pem cert.pem $out
'';
# Creates and set password for the 2 xmpp test users.
#
# Doing that in a bash script instead of doing that in the test
# script allow us to easily provision the users when running that
# test interactively.
createUsers = pkgs.writeShellScriptBin "create-prosody-users" ''
set -e
prosodyctl register alice example.com foobar
prosodyctl register john example.com foobar
'';
in
{
# Make the self-signed certificates work
security.pki.certificateFiles = [ "${cert}/cert.pem" ];
networking.extraHosts = ''
${config.networking.primaryIPAddress} example.com
${config.networking.primaryIPAddress} conference.example.com
${config.networking.primaryIPAddress} uploads.example.com
'';
environment.systemPackages = [
createUsers
];
# Configure Prosody with self-signed certificates
services.prosody = {
enable = true;
ssl.cert = "${cert}/cert.pem";
ssl.key = "${cert}/key.pem";
virtualHosts.example = {
enabled = true;
domain = "example.com";
ssl.cert = "${cert}/cert.pem";
ssl.key = "${cert}/key.pem";
};
muc = [ { domain = "conference.example.com"; } ];
httpFileShare = {
domain = "uploads.example.com";
};
};
networking.hosts."127.0.0.1" = [ "example.com" ];
}
|