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