1{ config, ... }:
2{
3 name = "nix-serve";
4 nodes.machine =
5 { pkgs, ... }:
6 {
7 services.nix-serve.enable = true;
8 environment.systemPackages = [
9 pkgs.hello
10 ];
11 };
12 testScript =
13 let
14 pkgHash = builtins.head (
15 builtins.match "${builtins.storeDir}/([^-]+).+" (toString config.node.pkgs.hello)
16 );
17 in
18 ''
19 start_all()
20 machine.wait_for_unit("nix-serve.service")
21 machine.wait_for_open_port(5000)
22 machine.succeed(
23 "curl --fail -g http://0.0.0.0:5000/nar/${pkgHash}.nar -o /tmp/hello.nar"
24 )
25 '';
26}