Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv }: 2 3let 4 foo = stdenv.mkDerivation { 5 name = "foo-test"; 6 7 dontUnpack = true; 8 9 installPhase = '' 10 mkdir -p $out/bin $out/include $out/lib 11 $CC -o $out/bin/foo ${./cc-main.c} 12 chmod +x $out/bin/foo 13 cp ${./foo.c} $out/include/foo.h 14 $CC -shared \ 15 ${lib.optionalString stdenv.isDarwin "-Wl,-install_name,$out/lib/libfoo.dylib"} \ 16 -o $out/lib/libfoo${stdenv.hostPlatform.extensions.sharedLibrary} \ 17 ${./foo.c} 18 ''; 19 }; 20 21 bar = stdenv.mkDerivation { 22 name = "bar-test"; 23 outputs = [ "out" "dev" ]; 24 25 dontUnpack = true; 26 27 installPhase = '' 28 mkdir -p $out/bin $dev/include $dev/lib 29 $CC -o $out/bin/bar ${./cc-main.c} 30 chmod +x $out/bin/bar 31 cp ${./bar.c} $dev/include/bar.h 32 $CC -shared \ 33 ${lib.optionalString stdenv.isDarwin "-Wl,-install_name,$dev/lib/libbar.dylib"} \ 34 -o $dev/lib/libbar${stdenv.hostPlatform.extensions.sharedLibrary} \ 35 ${./bar.c} 36 ''; 37 }; 38in 39 40stdenv.mkDerivation { 41 name = "stdenv-inputs-test"; 42 phases = [ "buildPhase" ]; 43 44 buildInputs = [ foo bar ]; 45 46 buildPhase = '' 47 env 48 49 printf "checking whether binaries are available... " >&2 50 foo && bar 51 52 printf "checking whether compiler can find headers... " >&2 53 $CC -o include-check ${./include-main.c} 54 ./include-check 55 56 printf "checking whether compiler can find headers... " >&2 57 $CC -o include-check ${./include-main.c} 58 ./include-check 59 60 printf "checking whether compiler can find libraries... " >&2 61 $CC -lfoo -lbar -o lib-check ${./lib-main.c} 62 ./lib-check 63 64 touch $out 65 ''; 66 67 meta.platforms = lib.platforms.all; 68}