1- let pkgs = import ./nix { } ; in
1+ { pkgs ? import ./nix { } } :
22
33with rec
44{
5+ surveyor-source = pkgs . lib . sourceByRegex ./.
6+ [ "^Makefile$"
7+ "^surveyor.c"
8+ ] ;
9+
10+ surveyor = pkgs . stdenv . mkDerivation
11+ { name = "surveyor" ;
12+ src = surveyor-source ;
13+ preConfigure = ''makeFlags="$makeFlags PREFIX=$out"'' ;
14+ } ;
15+
516 runTest = test : pkgs . runCommand "test"
617 { buildInputs = [ pkgs . netcat pkgs . curl pkgs . haskellPackages . wai-app-static ] ; }
718 ( test + "\n " + "touch $out" ) ;
@@ -39,7 +50,7 @@ let tests =
3950 ${ runPort 1234 }
4051
4152 SRV_MAP="*:80:*:1234" \
42- LD_PRELOAD="${ pkgs . surveyor } /lib/surveyor.so" \
53+ LD_PRELOAD="${ surveyor } /lib/surveyor.so" \
4354 curl localhost | grep -q '1234'
4455 '' ;
4556
@@ -49,7 +60,7 @@ let tests =
4960 ${ runPort 1234 }
5061
5162 SRV_MAP="192.168.42.42:*:127.0.0.1:*" \
52- LD_PRELOAD="${ pkgs . surveyor } /lib/surveyor.so" \
63+ LD_PRELOAD="${ surveyor } /lib/surveyor.so" \
5364 curl 192.168.42.42:1234 | grep -q '1234'
5465 '' ;
5566
@@ -62,9 +73,9 @@ let tests =
6273
6374 export SRV_MAP="*:1234:*:1235 *:1235:*:1234"
6475
65- LD_PRELOAD="${ pkgs . surveyor } /lib/surveyor.so" \
76+ LD_PRELOAD="${ surveyor } /lib/surveyor.so" \
6677 curl localhost:1234 | grep -q '1235'
67- LD_PRELOAD="${ pkgs . surveyor } /lib/surveyor.so" \
78+ LD_PRELOAD="${ surveyor } /lib/surveyor.so" \
6879 curl localhost:1235 | grep -q '1234'
6980 '' ;
7081
@@ -80,13 +91,12 @@ let tests =
8091 [ [ "0.0.0.42" "www.example.com" ] [ "0.0.0.43" "does.not.exist" ] ] }
8192
8293
83- LD_PRELOAD="${ pkgs . surveyor } /lib/surveyor.so ${ pkgs . libredirect } /lib/libredirect.so" \
94+ LD_PRELOAD="${ surveyor } /lib/surveyor.so ${ pkgs . libredirect } /lib/libredirect.so" \
8495 curl www.example.com | grep -q '1234'
85- LD_PRELOAD="${ pkgs . surveyor } /lib/surveyor.so ${ pkgs . libredirect } /lib/libredirect.so" \
96+ LD_PRELOAD="${ surveyor } /lib/surveyor.so ${ pkgs . libredirect } /lib/libredirect.so" \
8697 curl does.not.exist | grep -q '1235'
8798 '' ;
8899} ; in
89100
90- { inherit ( pkgs ) surveyor ;
91- inherit test_portMap ;
101+ { inherit surveyor ;
92102} // ( builtins . mapAttrs ( k : v : runTest v ) tests )
0 commit comments