summaryrefslogtreecommitdiffstats
path: root/nixos/tests/harmonia.nix
blob: 9e8b756e74ed88b0b52a09e17296e29c95f8ec7d (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
{ pkgs, lib, ... }:

{
  name = "harmonia";

  nodes = {
    harmonia = {
      services.harmonia.cache = {
        enable = true;
        signKeyPaths = [
          (pkgs.writeText "cache-key" "cache.example.com-1:9FhO0w+7HjZrhvmzT1VlAZw4OSAlFGTgC24Seg3tmPl4gZBdwZClzTTHr9cVzJpwsRSYLTu7hEAQe3ljy92CWg==")
        ];
        settings.priority = 35;
      };

      networking.firewall.allowedTCPPorts = [ 5000 ];
      system.extraDependencies = [ pkgs.emptyFile ];

      # check that extra-allowed-users is effective for harmonia
      nix.settings.allowed-users = [ ];
      nix.enable = true; # disabled by default. See all-tests.nix / tag(no-nix-by-default)
    };

    client01 = {
      nix.settings = {
        substituters = lib.mkForce [ "http://harmonia:5000" ];
        trusted-public-keys = lib.mkForce [
          "cache.example.com-1:eIGQXcGQpc00x6/XFcyacLEUmC07u4RAEHt5Y8vdglo="
        ];
      };
      nix.enable = true; # disabled by default. See all-tests.nix / tag(no-nix-by-default)
    };
  };

  testScript =
    { nodes, ... }:
    ''
      start_all()

      harmonia.wait_for_unit("harmonia.socket")

      client01.wait_until_succeeds("curl -f http://harmonia:5000/nix-cache-info | grep '${toString nodes.harmonia.services.harmonia.cache.settings.priority}' >&2")
      client01.succeed("curl -f http://harmonia:5000/version | grep '${nodes.harmonia.services.harmonia.package.version}' >&2")

      client01.succeed("cat /etc/nix/nix.conf >&2")
      client01.succeed("nix-store --realise ${pkgs.emptyFile} --store /root/other-store")
    '';
}