nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.hostPlatform.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 = [
24 "out"
25 "dev"
26 ];
27
28 dontUnpack = true;
29
30 installPhase = ''
31 mkdir -p $out/bin $dev/include $dev/lib
32 $CC -o $out/bin/bar ${./cc-main.c}
33 chmod +x $out/bin/bar
34 cp ${./bar.c} $dev/include/bar.h
35 $CC -shared \
36 ${lib.optionalString stdenv.hostPlatform.isDarwin "-Wl,-install_name,$dev/lib/libbar.dylib"} \
37 -o $dev/lib/libbar${stdenv.hostPlatform.extensions.sharedLibrary} \
38 ${./bar.c}
39 '';
40 };
41in
42
43stdenv.mkDerivation {
44 name = "stdenv-inputs-test";
45
46 buildInputs = [
47 foo
48 bar
49 ];
50
51 buildCommand = ''
52 env
53
54 printf "checking whether binaries are available... " >&2
55 foo && bar
56
57 printf "checking whether compiler can find headers... " >&2
58 $CC -o include-check ${./include-main.c}
59 ./include-check
60
61 printf "checking whether compiler can find headers... " >&2
62 $CC -o include-check ${./include-main.c}
63 ./include-check
64
65 printf "checking whether compiler can find libraries... " >&2
66 $CC -lfoo -lbar -o lib-check ${./lib-main.c}
67 ./lib-check
68
69 touch $out
70 '';
71
72 meta.platforms = lib.platforms.all;
73 passthru = {
74 inherit foo bar;
75 };
76}