1 # Testing out the substitute server with two machines in a local network. As a
2 # bonus, we'll also test a feature of the substitute server being able to
3 # advertise its service to the local network with Avahi.
5 import ../make-test-python.nix (
9 inherit (builtins) toString;
12 name = "guix-publish";
14 meta.maintainers = with lib.maintainers; [ foo-dogsquared ];
21 # We'll be using '--advertise' flag with the
22 # substitute server which requires Avahi.
42 imports = [ commonConfig ];
50 generateKeyPair = true;
51 extraArgs = [ "--advertise" ];
55 networking.firewall.allowedTCPPorts = [ publishPort ];
66 imports = [ commonConfig ];
71 # Force to only get all substitutes from the local server. We don't
72 # have anything in the Guix store directory and we cannot get
73 # anything from the official substitute servers anyways.
74 substituters.urls = [ "http://server.local:${toString publishPort}" ];
77 # Enable autodiscovery of the substitute servers in the local
78 # network. This machine shouldn't need to import the signing key from
79 # the substitute server since it is automatically done anyways.
91 scripts_dir = pathlib.Path("/etc/guix/scripts")
93 for machine in machines:
94 machine.wait_for_unit("multi-user.target")
95 machine.wait_for_unit("guix-daemon.service")
96 machine.wait_for_unit("avahi-daemon.service")
98 server.wait_for_unit("guix-publish.service")
99 server.wait_for_open_port(${toString publishPort})
100 server.succeed("curl http://localhost:${toString publishPort}/")
102 # Now it's the client turn to make use of it.
103 substitute_server = "http://server.local:${toString publishPort}"
104 client.systemctl("start network-online.target")
105 client.wait_for_unit("network-online.target")
106 response = client.succeed(f"curl {substitute_server}")
107 assert "Guix Substitute Server" in response
109 # Authorizing the server to be used as a substitute server.
110 client.succeed(f"curl -O {substitute_server}/signing-key.pub")
111 client.succeed("guix archive --authorize < ./signing-key.pub")
113 # Since we're using the substitute server with the `--advertise` flag, we
114 # might as well check it.
115 client.succeed("avahi-browse --resolve --terminate _guix_publish._tcp | grep '_guix_publish._tcp'")