at 23.05-pre 1.4 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, lib, ... }: 3 { 4 name = "nar-serve"; 5 meta.maintainers = [ lib.maintainers.rizary ]; 6 nodes = 7 { 8 server = { pkgs, ... }: { 9 services.nginx = { 10 enable = true; 11 virtualHosts.default.root = "/var/www"; 12 }; 13 services.nar-serve = { 14 enable = true; 15 # Connect to the localhost nginx instead of the default 16 # https://cache.nixos.org 17 cacheURL = "http://localhost/"; 18 }; 19 environment.systemPackages = [ 20 pkgs.hello 21 pkgs.curl 22 ]; 23 24 networking.firewall.allowedTCPPorts = [ 8383 ]; 25 26 # virtualisation.diskSize = 2 * 1024; 27 }; 28 }; 29 testScript = '' 30 start_all() 31 32 # Create a fake cache with Nginx service the static files 33 server.succeed( 34 "nix --experimental-features nix-command copy --to file:///var/www ${pkgs.hello}" 35 ) 36 server.wait_for_unit("nginx.service") 37 server.wait_for_open_port(80) 38 39 # Check that nar-serve can return the content of the derivation 40 drvName = os.path.basename("${pkgs.hello}") 41 drvHash = drvName.split("-")[0] 42 server.wait_for_unit("nar-serve.service") 43 server.succeed( 44 "curl -o hello -f http://localhost:8383/nix/store/{}/bin/hello".format(drvHash) 45 ) 46 ''; 47 } 48)