This repository has no description
1{
2 fetch,
3 run,
4 lib,
5 config,
6
7 clang-host ? clang,
8 clang,
9 compiler-rt,
10 gnumake,
11 linux,
12 lld,
13 llvm,
14 musl,
15}:
16
17run
18 {
19 name = "busybox";
20 src = fetch.github {
21 owner = "tombl";
22 repo = "busybox";
23 rev = "refs/heads/master";
24 hash = "sha256-Rlgj229jP+I/x3mdgilY6FHu1IDyAwpQc/pqBzQIasU=";
25 };
26 path = [
27 clang
28 gnumake
29 lld
30 llvm
31 ];
32 }
33 ''
34 make() {
35 command make -j$NIX_BUILD_CORES \
36 ARCH=wasm32 \
37 HOSTCC=${clang-host}/bin/clang \
38 CC=${clang}/bin/clang \
39 CFLAGS_busybox="${musl}/lib/crt1.o -Wl,--import-memory" "$@"
40 }
41
42 config() {
43 sed -i "/CONFIG_$1=/d" .config
44 sed -i "/CONFIG_$1 is not set/d" .config
45 case $2 in
46 y|n) echo "CONFIG_$1=$2" >> .config ;;
47 *) echo "CONFIG_$1=\"$2\"" >> .config ;;
48 esac
49 }
50
51 make defconfig
52 config STATIC y
53 config NOMMU y
54 config STATIC_LIBGCC n
55 config CROSS_COMPILER_PREFIX llvm-
56 config SYSROOT ${musl}
57 config EXTRA_CFLAGS '-nostdlib -isystem ${musl}/include -I${linux.headers}/include ${lib.optionalString config.debug "-g"}'
58 config EXTRA_LDFLAGS ${compiler-rt}/libclang_rt.builtins-wasm32.a
59 config EXTRA_LDLIBS c
60
61 cat .config
62 make oldconfig
63
64 make
65
66 mkdir -p $out/bin
67 cp busybox $out/bin
68 ''