1 import ../make-test-python.nix (
5 certs = import ../common/acme/server/snakeoil-certs.nix;
7 serverDomain = certs.domain;
11 password = "snakeoilpass";
13 # An API token that we manually insert into the db as a valid one.
14 apiToken = "OVJh65sXaAfQMZ4NTcIGbFZIyBZbEZqWTi7azdDf";
18 meta.maintainers = with pkgs.lib.maintainers; [ erictapen ];
23 virtualisation.memorySize = 2048;
27 localDomain = "${serverDomain}";
28 djangoSecretKeyFile = pkgs.writeText "weblate-django-secret" "thisissnakeoilsecretwithmorethan50characterscorrecthorsebatterystaple";
30 # Weblate tries to fetch Avatars from the network
31 ENABLE_AVATARS = False
35 services.nginx.virtualHosts."${serverDomain}" = {
36 enableACME = lib.mkForce false;
37 sslCertificate = certs."${serverDomain}".cert;
38 sslCertificateKey = certs."${serverDomain}".key;
41 security.pki.certificateFiles = [ certs.ca.cert ];
43 networking.hosts."::1" = [ "${serverDomain}" ];
44 networking.firewall.allowedTCPPorts = [
49 users.users.weblate.shell = pkgs.bashInteractive;
55 environment.systemPackages = [ pkgs.wlc ];
57 environment.etc."xdg/weblate".text = ''
59 url = https://${serverDomain}/api/
63 networking.hosts."${nodes.server.networking.primaryIPAddress}" = [ "${serverDomain}" ];
65 security.pki.certificateFiles = [ certs.ca.cert ];
72 server.wait_for_unit("weblate.socket")
73 server.wait_until_succeeds("curl -f https://${serverDomain}/")
74 server.succeed("sudo -iu weblate -- weblate createadmin --username ${admin.username} --password ${admin.password} --email weblate@example.org")
76 # It's easier to replace the generated API token with a predefined one than
77 # to extract it at runtime.
78 server.succeed("sudo -iu weblate -- psql -d weblate -c \"UPDATE authtoken_token SET key = '${apiToken}' WHERE user_id = (SELECT id FROM weblate_auth_user WHERE username = 'admin');\"")
80 client.wait_for_unit("multi-user.target")
82 # Test the official Weblate client wlc.
83 client.wait_until_succeeds("REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt wlc --debug list-projects")
86 (rv, result) = client.execute("curl -H \"Content-Type: application/json\" -H \"Authorization: Token ${apiToken}\" https://${serverDomain}/api/{}".format(arg))
90 call_wl_api("users/ --data '{}'".format(
94 "email": "test1@example.org"
97 # TODO: Check sending and receiving email.
98 # server.wait_for_unit("postfix.service")
100 # TODO: The goal is for this to succeed, but there are still some checks failing.
101 # server.succeed("sudo -iu weblate -- weblate check --deploy")