about summary refs log tree commit diff
path: root/nixos/tests/nix-serve.nix
blob: 3aa913f81107a4664f29f214c3bb1bbd294c121f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import ./make-test-python.nix ({ pkgs, ... }:
{
  name = "nix-serve";
  nodes.machine = { pkgs, ... }: {
    services.nix-serve.enable = true;
    environment.systemPackages = [
      pkgs.hello
    ];
  };
  testScript = let
    pkgHash = builtins.head (
      builtins.match "${builtins.storeDir}/([^-]+).+" (toString pkgs.hello)
    );
  in ''
    start_all()
    machine.wait_for_unit("nix-serve.service")
    machine.wait_for_open_port(5000)
    machine.succeed(
        "curl --fail -g http://0.0.0.0:5000/nar/${pkgHash}.nar -o /tmp/hello.nar"
    )
  '';
})