1{ pkgs, ... }:
2let
3 cert = pkgs.runCommand "selfSignedCerts" { nativeBuildInputs = [ pkgs.openssl ]; } ''
4 openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=localhost' -days 36500
5 mkdir -p $out
6 cp key.pem cert.pem $out
7 '';
8in
9{
10 name = "monica";
11
12 nodes = {
13 machine =
14 { pkgs, ... }:
15 {
16 services.monica = {
17 enable = true;
18 hostname = "localhost";
19 appKeyFile = "${pkgs.writeText "keyfile" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}";
20 nginx = {
21 forceSSL = true;
22 sslCertificate = "${cert}/cert.pem";
23 sslCertificateKey = "${cert}/key.pem";
24 };
25 };
26 };
27 };
28
29 testScript = ''
30 start_all()
31 machine.wait_for_unit("monica-setup.service")
32 machine.wait_for_open_port(443)
33 machine.succeed("curl -k --fail https://localhost", timeout=10)
34 '';
35}