1{
2 system ? builtins.currentSystem
3, pkgs ? import ../.. { inherit system; }
4, package
5}:
6import ./make-test-python.nix ({ pkgs, ... }: let
7 testPath = pkgs.hello;
8in {
9 name = "varnish";
10 meta = with pkgs.lib.maintainers; {
11 maintainers = [ ajs124 ];
12 };
13
14 nodes = {
15 varnish = { config, pkgs, ... }: {
16 services.nix-serve = {
17 enable = true;
18 };
19
20 services.varnish = {
21 inherit package;
22 enable = true;
23 http_address = "0.0.0.0:80";
24 config = ''
25 vcl 4.0;
26
27 backend nix-serve {
28 .host = "127.0.0.1";
29 .port = "${toString config.services.nix-serve.port}";
30 }
31 '';
32 };
33
34 networking.firewall.allowedTCPPorts = [ 80 ];
35 system.extraDependencies = [ testPath ];
36 };
37
38 client = { lib, ... }: {
39 nix.settings = {
40 require-sigs = false;
41 substituters = lib.mkForce [ "http://varnish" ];
42 };
43 };
44 };
45
46 testScript = ''
47 start_all()
48 varnish.wait_for_open_port(80)
49
50 client.wait_until_succeeds("curl -f http://varnish/nix-cache-info");
51
52 client.wait_until_succeeds("nix-store -r ${testPath}");
53 client.succeed("${testPath}/bin/hello");
54 '';
55})