Merge pull request #305845 from abathur/resholve_0.10.5
[NixPkgs.git] / nixos / tests / nar-serve.nix
blobf6197567b822a8c06ba54784a890a3b33f304298
1 import ./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           ];
24           networking.firewall.allowedTCPPorts = [ 8383 ];
26           # virtualisation.diskSize = 2 * 1024;
27         };
28       };
29     testScript = ''
30       import os
32       start_all()
34       # Create a fake cache with Nginx service the static files
35       server.succeed(
36           "nix --experimental-features nix-command copy --to file:///var/www ${pkgs.hello}"
37       )
38       server.wait_for_unit("nginx.service")
39       server.wait_for_open_port(80)
41       # Check that nar-serve can return the content of the derivation
42       drvName = os.path.basename("${pkgs.hello}")
43       drvHash = drvName.split("-")[0]
44       server.wait_for_unit("nar-serve.service")
45       server.succeed(
46           "curl -o hello -f http://localhost:8383/nix/store/{}/bin/hello".format(drvHash)
47       )
48     '';
49   }