-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefault.nix
144 lines (118 loc) · 4.47 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
let
# stage 0
# these two use nixpkgs, but are fixed-output derivations with no dependencies
tcc-seed = (import ./using-nix/0.nix).tinycc;
protosrc = (import ./using-nix/0.nix).protosrc;
# in bootstrapping builds,
# 0.nix is different and they're not coming from nixpkgs,
# see recipes/4-rebootstrap-using-nix.sh
# stage 1
stage1 = (import ./using-nix/1-stage1.nix) {
inherit tcc-seed protosrc;
recipesStage1ExtrasPath = ./recipes/1-stage1;
stage1cPath = ./recipes/1-stage1.c;
}; # multioutput, offers .protobusybox, .protomusl and .tinycc
# stage 2
mkCaDerivation = args: derivation (args // {
system = "x86_64-linux";
__contentAddressed = true;
outputHashAlgo = "sha256"; outputHashMode = "recursive";
});
mkDerivationStage2 =
{name, script, buildInputPaths, extra ? {}}: mkCaDerivation {
inherit name;
builder = "${stage1.protobusybox}/bin/ash";
args = [ "-uexc" (
''
export PATH=${builtins.concatStringsSep ":" buildInputPaths}
if [ -e /ccache/setup ]; then
. /ccache/setup bootstrap-from-tcc/${name}
fi
unpack() (tar --strip-components=1 -xf "$@")
if [ -n "$NIX_BUILD_CORES" ] && [ "$NIX_BUILD_CORES" != 0 ]; then
NPROC=$NIX_BUILD_CORES
elif [ "$NIX_BUILD_CORES" == 0 ] && [ -r /proc/cpuinfo ]; then
NPROC=$(grep -c processor /proc/cpuinfo)
else
NPROC=1
fi
'' + script
) ];
} // extra;
fetchurl = { url, sha256 }: derivation {
name = builtins.baseNameOf url;
inherit url;
urls = [ url ];
unpack = false;
builder = "builtin:fetchurl";
system = "builtin";
outputHashMode = "flat"; outputHashAlgo = "sha256";
preferLocalBuild = true;
outputHash = sha256;
};
static-gnumake = (import using-nix/2a0-static-gnumake.nix) {
inherit fetchurl mkDerivationStage2 stage1;
};
static-binutils = (import using-nix/2a1-static-binutils.nix) {
inherit fetchurl mkDerivationStage2 stage1 static-gnumake;
};
static-gnugcc4-c = (import using-nix/2a2-static-gnugcc4-c.nix) {
inherit fetchurl mkDerivationStage2 stage1 static-gnumake static-binutils;
};
intermediate-musl = (import using-nix/2a3-intermediate-musl.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils static-gnugcc4-c;
};
gnugcc4-cpp = (import using-nix/2a4-gnugcc4-cpp.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils static-gnugcc4-c;
inherit intermediate-musl;
};
gnugcc10 = (import using-nix/2a5-gnugcc10.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils gnugcc4-cpp intermediate-musl;
};
linux-headers = (import using-nix/2a6-linux-headers.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils gnugcc10;
};
cmake = (import using-nix/2a7-cmake.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils gnugcc10 linux-headers;
};
python = (import using-nix/2a8-python.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils gnugcc10;
};
intermediate-clang = (import using-nix/2a9-intermediate-clang.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake static-binutils intermediate-musl gnugcc10;
inherit linux-headers cmake python;
};
musl = (import using-nix/2b0-musl.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake intermediate-clang;
};
clang = (import using-nix/2b1-clang.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake musl intermediate-clang;
inherit linux-headers cmake python;
};
busybox = (import using-nix/2b2-busybox.nix) {
inherit fetchurl mkDerivationStage2;
inherit stage1 static-gnumake musl clang linux-headers;
};
in
{
# exposed just because; don't rely on these
inherit protosrc tcc-seed;
inherit stage1;
inherit static-gnumake static-binutils static-gnugcc4-c;
inherit intermediate-musl gnugcc4-cpp gnugcc10;
inherit linux-headers cmake python intermediate-clang;
inherit musl clang;
# public interface:
libc = musl; # some libc that TODO: doesn't depend on anything else
toolchain = clang; # some modern C/C++ compiler targeting this libc
busybox = busybox; # a freebie busybox TODO: depending on just libc
}