1{ lib, ... }:
2
3let
4 meilisearchKey = "TESTKEY-naXRkVX7nhvLaGOmGGuicDKxZAj0khEaoOZPeEZafv8w9j8V6aKb0NVdXRChL5kR";
5in
6{
7 name = "sharkey";
8
9 nodes.machine =
10 { pkgs, ... }:
11 {
12 services.sharkey = {
13 enable = true;
14 setupMeilisearch = true;
15 environmentFiles = [ "/run/secrets/sharkey-env" ];
16 settings = {
17 url = "http://exampleurl.invalid";
18 meilisearch.index = "exampleurl_invalid";
19 };
20 };
21
22 services.meilisearch.masterKeyFile = pkgs.writeText "meilisearch-key" meilisearchKey;
23 };
24
25 testScript =
26 let
27 createIndexPayload = builtins.toJSON {
28 description = "Sharkey API key";
29 actions = [ "*" ];
30 indexes = [ "exampleurl_invalid---notes" ];
31 expiresAt = null;
32 };
33 in
34 ''
35 import json
36
37 with subtest("Setting up Meilisearch API key and index"):
38 machine.wait_for_unit("meilisearch.service")
39 machine.wait_for_open_port(7700)
40
41 json_body = '${createIndexPayload}'
42 create_index_result = json.loads(machine.succeed(f"curl -s -X POST 'http://localhost:7700/keys' -H 'Content-Type: application/json' -H 'Authorization: Bearer ${meilisearchKey}' --data-binary '{json_body}'"))
43 machine.succeed(f"mkdir /run/secrets; echo 'MK_CONFIG_MEILISEARCH_APIKEY={create_index_result["key"]}' > /run/secrets/sharkey-env")
44
45 with subtest("Testing Sharkey is running and listening to HTTP requests"):
46 machine.systemctl("restart sharkey")
47 machine.wait_for_open_port(3000)
48
49 machine.succeed("curl --fail http://localhost:3000")
50 '';
51
52 meta.maintainers = with lib.maintainers; [
53 tmarkus
54 ];
55}