1{ lib, ... }:
2{
3 name = "reposilite";
4
5 nodes = {
6 machine =
7 { pkgs, ... }:
8 {
9 services = {
10 mysql = {
11 enable = true;
12 package = pkgs.mariadb;
13 ensureDatabases = [ "reposilite" ];
14 initialScript = pkgs.writeText "reposilite-test-db-init" ''
15 CREATE USER 'reposilite'@'localhost' IDENTIFIED BY 'ReposiliteDBPass';
16 GRANT ALL PRIVILEGES ON reposilite.* TO 'reposilite'@'localhost';
17 FLUSH PRIVILEGES;
18 '';
19 };
20
21 reposilite = {
22 enable = true;
23 plugins = with pkgs.reposilitePlugins; [
24 checksum
25 groovy
26 ];
27 extraArgs = [
28 "--token"
29 "test:SuperSecretTestToken"
30 ];
31 database = {
32 type = "mariadb";
33 passwordFile = "/run/reposiliteDbPass";
34 };
35 settings.port = 8080;
36 };
37 };
38 };
39 };
40
41 testScript = ''
42 machine.start()
43
44 machine.execute("echo \"ReposiliteDBPass\" > /run/reposiliteDbPass && chmod 600 /run/reposiliteDbPass && chown reposilite:reposilite /run/reposiliteDbPass")
45 machine.wait_for_unit("reposilite.service")
46 machine.wait_for_open_port(8080)
47
48 machine.fail("curl -Sf localhost:8080/api/auth/me")
49 machine.succeed("curl -Sfu test:SuperSecretTestToken localhost:8080/api/auth/me")
50 '';
51
52 meta.maintainers = [ lib.maintainers.uku3lig ];
53}