Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 binutils,
5 busybox,
6 bootstrapTools,
7 hello,
8}:
9
10builtins.derivation {
11 name = "test-bootstrap-tools";
12 inherit (stdenv.hostPlatform) system; # We cannot "cross test"
13 builder = busybox;
14 args = [
15 "ash"
16 "-e"
17 "-c"
18 "eval \"$buildCommand\""
19 ];
20
21 buildCommand = ''
22 export PATH=${bootstrapTools}/bin
23
24 ls -l
25 mkdir $out
26 mkdir $out/bin
27 sed --version
28 find --version
29 diff --version
30 patch --version
31 make --version
32 awk --version
33 grep --version
34 gcc --version
35
36 ''
37 + lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
38 rtld=$(echo ${bootstrapTools}/lib/${builtins.unsafeDiscardStringContext # only basename
39 (builtins.baseNameOf binutils.dynamicLinker)})
40 libc_includes=${bootstrapTools}/include-glibc
41 ''
42 + lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
43 rtld=$(echo ${bootstrapTools}/lib/ld-musl*.so.?)
44 libc_includes=${bootstrapTools}/include-libc
45 ''
46 + ''
47 # path to version-specific libraries, like libstdc++.so
48 cxx_libs=$(echo ${bootstrapTools}/lib/gcc/*/*)
49 export CPP="cpp -idirafter $libc_includes -B${bootstrapTools}"
50 export CC="gcc -idirafter $libc_includes -B${bootstrapTools} -Wl,-dynamic-linker,$rtld -Wl,-rpath,${bootstrapTools}/lib -Wl,-rpath,$cxx_libs"
51 export CXX="g++ -idirafter $libc_includes -B${bootstrapTools} -Wl,-dynamic-linker,$rtld -Wl,-rpath,${bootstrapTools}/lib -Wl,-rpath,$cxx_libs"
52
53 echo '#include <stdio.h>' >> foo.c
54 echo '#include <limits.h>' >> foo.c
55 echo 'int main() { printf("Hello World\\n"); return 0; }' >> foo.c
56 $CC -o $out/bin/foo foo.c
57 $out/bin/foo
58
59 echo '#include <iostream>' >> bar.cc
60 echo 'int main() { std::cout << "Hello World\\n"; }' >> bar.cc
61 $CXX -v -o $out/bin/bar bar.cc
62 $out/bin/bar
63
64 tar xvf ${hello.src}
65 cd hello-*
66 ./configure --prefix=$out
67 make
68 make install
69 '';
70}