1{ lib }:
2rec {
3 pcBase = {
4 name = "pc";
5 kernelBaseConfig = "defconfig";
6 # Build whatever possible as a module, if not stated in the extra config.
7 kernelAutoModules = true;
8 kernelTarget = "bzImage";
9 };
10
11 pc64 = pcBase // { kernelArch = "x86_64"; };
12
13 pc32 = pcBase // { kernelArch = "i386"; };
14
15 pc32_simplekernel = pc32 // {
16 kernelAutoModules = false;
17 };
18
19 pc64_simplekernel = pc64 // {
20 kernelAutoModules = false;
21 };
22
23 powernv = {
24 name = "PowerNV";
25 kernelArch = "powerpc";
26 kernelBaseConfig = "powernv_defconfig";
27 kernelTarget = "zImage";
28 kernelInstallTarget = "install";
29 kernelFile = "vmlinux";
30 kernelAutoModules = true;
31 # avoid driver/FS trouble arising from unusual page size
32 kernelExtraConfig = ''
33 PPC_64K_PAGES n
34 PPC_4K_PAGES y
35 IPV6 y
36 '';
37 };
38
39 ##
40 ## ARM
41 ##
42
43 pogoplug4 = {
44 name = "pogoplug4";
45
46 gcc = {
47 arch = "armv5te";
48 };
49
50 kernelMajor = "2.6";
51 kernelBaseConfig = "multi_v5_defconfig";
52 kernelArch = "arm";
53 kernelAutoModules = false;
54 kernelExtraConfig =
55 ''
56 # Ubi for the mtd
57 MTD_UBI y
58 UBIFS_FS y
59 UBIFS_FS_XATTR y
60 UBIFS_FS_ADVANCED_COMPR y
61 UBIFS_FS_LZO y
62 UBIFS_FS_ZLIB y
63 UBIFS_FS_DEBUG n
64 '';
65 kernelMakeFlags = [ "LOADADDR=0x8000" ];
66 kernelTarget = "uImage";
67 # TODO reenable once manual-config's config actually builds a .dtb and this is checked to be working
68 #kernelDTB = true;
69 };
70
71 sheevaplug = {
72 name = "sheevaplug";
73 kernelMajor = "2.6";
74 kernelBaseConfig = "multi_v5_defconfig";
75 kernelArch = "arm";
76 kernelAutoModules = false;
77 kernelExtraConfig = ''
78 BLK_DEV_RAM y
79 BLK_DEV_INITRD y
80 BLK_DEV_CRYPTOLOOP m
81 BLK_DEV_DM m
82 DM_CRYPT m
83 MD y
84 REISERFS_FS m
85 BTRFS_FS m
86 XFS_FS m
87 JFS_FS m
88 EXT4_FS m
89 USB_STORAGE_CYPRESS_ATACB m
90
91 # mv cesa requires this sw fallback, for mv-sha1
92 CRYPTO_SHA1 y
93 # Fast crypto
94 CRYPTO_TWOFISH y
95 CRYPTO_TWOFISH_COMMON y
96 CRYPTO_BLOWFISH y
97 CRYPTO_BLOWFISH_COMMON y
98
99 IP_PNP y
100 IP_PNP_DHCP y
101 NFS_FS y
102 ROOT_NFS y
103 TUN m
104 NFS_V4 y
105 NFS_V4_1 y
106 NFS_FSCACHE y
107 NFSD m
108 NFSD_V2_ACL y
109 NFSD_V3 y
110 NFSD_V3_ACL y
111 NFSD_V4 y
112 NETFILTER y
113 IP_NF_IPTABLES y
114 IP_NF_FILTER y
115 IP_NF_MATCH_ADDRTYPE y
116 IP_NF_TARGET_LOG y
117 IP_NF_MANGLE y
118 IPV6 m
119 VLAN_8021Q m
120
121 CIFS y
122 CIFS_XATTR y
123 CIFS_POSIX y
124 CIFS_FSCACHE y
125 CIFS_ACL y
126
127 WATCHDOG y
128 WATCHDOG_CORE y
129 ORION_WATCHDOG m
130
131 ZRAM m
132 NETCONSOLE m
133
134 # Disable OABI to have seccomp_filter (required for systemd)
135 # https://github.com/raspberrypi/firmware/issues/651
136 OABI_COMPAT n
137
138 # Fail to build
139 DRM n
140 SCSI_ADVANSYS n
141 USB_ISP1362_HCD n
142 SND_SOC n
143 SND_ALI5451 n
144 FB_SAVAGE n
145 SCSI_NSP32 n
146 ATA_SFF n
147 SUNGEM n
148 IRDA n
149 ATM_HE n
150 SCSI_ACARD n
151 BLK_DEV_CMD640_ENHANCED n
152
153 FUSE_FS m
154
155 # systemd uses cgroups
156 CGROUPS y
157
158 # Latencytop
159 LATENCYTOP y
160
161 # Ubi for the mtd
162 MTD_UBI y
163 UBIFS_FS y
164 UBIFS_FS_XATTR y
165 UBIFS_FS_ADVANCED_COMPR y
166 UBIFS_FS_LZO y
167 UBIFS_FS_ZLIB y
168 UBIFS_FS_DEBUG n
169
170 # Kdb, for kernel troubles
171 KGDB y
172 KGDB_SERIAL_CONSOLE y
173 KGDB_KDB y
174 '';
175 kernelMakeFlags = [ "LOADADDR=0x0200000" ];
176 kernelTarget = "uImage";
177 kernelDTB = true; # Beyond 3.10
178 gcc = {
179 arch = "armv5te";
180 };
181 };
182
183 raspberrypi = {
184 name = "raspberrypi";
185 kernelMajor = "2.6";
186 kernelBaseConfig = "bcm2835_defconfig";
187 kernelDTB = true;
188 kernelArch = "arm";
189 kernelAutoModules = true;
190 kernelPreferBuiltin = true;
191 kernelExtraConfig = ''
192 # Disable OABI to have seccomp_filter (required for systemd)
193 # https://github.com/raspberrypi/firmware/issues/651
194 OABI_COMPAT n
195 '';
196 kernelTarget = "zImage";
197 gcc = {
198 arch = "armv6";
199 fpu = "vfp";
200 };
201 };
202
203 # Legacy attribute, for compatibility with existing configs only.
204 raspberrypi2 = armv7l-hf-multiplatform;
205
206 scaleway-c1 = armv7l-hf-multiplatform // {
207 gcc = {
208 cpu = "cortex-a9";
209 fpu = "vfpv3";
210 };
211 };
212
213 utilite = {
214 name = "utilite";
215 kernelMajor = "2.6";
216 kernelBaseConfig = "multi_v7_defconfig";
217 kernelArch = "arm";
218 kernelAutoModules = false;
219 kernelExtraConfig =
220 ''
221 # Ubi for the mtd
222 MTD_UBI y
223 UBIFS_FS y
224 UBIFS_FS_XATTR y
225 UBIFS_FS_ADVANCED_COMPR y
226 UBIFS_FS_LZO y
227 UBIFS_FS_ZLIB y
228 UBIFS_FS_DEBUG n
229 '';
230 kernelMakeFlags = [ "LOADADDR=0x10800000" ];
231 kernelTarget = "uImage";
232 kernelDTB = true;
233 gcc = {
234 cpu = "cortex-a9";
235 fpu = "neon";
236 };
237 };
238
239 guruplug = sheevaplug // {
240 # Define `CONFIG_MACH_GURUPLUG' (see
241 # <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>)
242 # and other GuruPlug-specific things. Requires the `guruplug-defconfig'
243 # patch.
244
245 kernelBaseConfig = "guruplug_defconfig";
246 };
247
248 beaglebone = armv7l-hf-multiplatform // {
249 name = "beaglebone";
250 kernelBaseConfig = "bb.org_defconfig";
251 kernelAutoModules = false;
252 kernelExtraConfig = ""; # TBD kernel config
253 kernelTarget = "zImage";
254 };
255
256 # https://developer.android.com/ndk/guides/abis#armeabi
257 armv5te-android = {
258 name = "armeabi";
259 gcc = {
260 arch = "armv5te";
261 float = "soft";
262 float-abi = "soft";
263 };
264 };
265
266 # https://developer.android.com/ndk/guides/abis#v7a
267 armv7a-android = {
268 name = "armeabi-v7a";
269 gcc = {
270 arch = "armv7-a";
271 float = "hard";
272 float-abi = "softfp";
273 fpu = "vfpv3-d16";
274 };
275 };
276
277 armv7l-hf-multiplatform = {
278 name = "armv7l-hf-multiplatform";
279 kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
280 kernelBaseConfig = "multi_v7_defconfig";
281 kernelArch = "arm";
282 kernelDTB = true;
283 kernelAutoModules = true;
284 kernelPreferBuiltin = true;
285 kernelTarget = "zImage";
286 kernelExtraConfig = ''
287 # Serial port for Raspberry Pi 3. Upstream forgot to add it to the ARMv7 defconfig.
288 SERIAL_8250_BCM2835AUX y
289 SERIAL_8250_EXTENDED y
290 SERIAL_8250_SHARE_IRQ y
291
292 # Fix broken sunxi-sid nvmem driver.
293 TI_CPTS y
294
295 # Hangs ODROID-XU4
296 ARM_BIG_LITTLE_CPUIDLE n
297
298 # Disable OABI to have seccomp_filter (required for systemd)
299 # https://github.com/raspberrypi/firmware/issues/651
300 OABI_COMPAT n
301 '';
302 gcc = {
303 # Some table about fpu flags:
304 # http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png
305 # Cortex-A5: -mfpu=neon-fp16
306 # Cortex-A7 (rpi2): -mfpu=neon-vfpv4
307 # Cortex-A8 (beaglebone): -mfpu=neon
308 # Cortex-A9: -mfpu=neon-fp16
309 # Cortex-A15: -mfpu=neon-vfpv4
310
311 # More about FPU:
312 # https://wiki.debian.org/ArmHardFloatPort/VfpComparison
313
314 # vfpv3-d16 is what Debian uses and seems to be the best compromise: NEON is not supported in e.g. Scaleway or Tegra 2,
315 # and the above page suggests NEON is only an improvement with hand-written assembly.
316 arch = "armv7-a";
317 fpu = "vfpv3-d16";
318
319 # For Raspberry Pi the 2 the best would be:
320 # cpu = "cortex-a7";
321 # fpu = "neon-vfpv4";
322 };
323 };
324
325 aarch64-multiplatform = {
326 name = "aarch64-multiplatform";
327 kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
328 kernelBaseConfig = "defconfig";
329 kernelArch = "arm64";
330 kernelDTB = true;
331 kernelAutoModules = true;
332 kernelPreferBuiltin = true;
333 kernelExtraConfig = ''
334 # Raspberry Pi 3 stuff. Not needed for kernels >= 4.10.
335 ARCH_BCM2835 y
336 BCM2835_MBOX y
337 BCM2835_WDT y
338 RASPBERRYPI_FIRMWARE y
339 RASPBERRYPI_POWER y
340 SERIAL_8250_BCM2835AUX y
341 SERIAL_8250_EXTENDED y
342 SERIAL_8250_SHARE_IRQ y
343
344 # Cavium ThunderX stuff.
345 PCI_HOST_THUNDER_ECAM y
346
347 # Nvidia Tegra stuff.
348 PCI_TEGRA y
349
350 # The default (=y) forces us to have the XHCI firmware available in initrd,
351 # which our initrd builder can't currently do easily.
352 USB_XHCI_TEGRA m
353 '';
354 kernelTarget = "Image";
355 gcc = {
356 arch = "armv8-a";
357 };
358 };
359
360 ##
361 ## MIPS
362 ##
363
364 ben_nanonote = {
365 name = "ben_nanonote";
366 kernelMajor = "2.6";
367 kernelArch = "mips";
368 gcc = {
369 arch = "mips32";
370 float = "soft";
371 };
372 };
373
374 fuloong2f_n32 = {
375 name = "fuloong2f_n32";
376 kernelMajor = "2.6";
377 kernelBaseConfig = "lemote2f_defconfig";
378 kernelArch = "mips";
379 kernelAutoModules = false;
380 kernelExtraConfig = ''
381 MIGRATION n
382 COMPACTION n
383
384 # nixos mounts some cgroup
385 CGROUPS y
386
387 BLK_DEV_RAM y
388 BLK_DEV_INITRD y
389 BLK_DEV_CRYPTOLOOP m
390 BLK_DEV_DM m
391 DM_CRYPT m
392 MD y
393 REISERFS_FS m
394 EXT4_FS m
395 USB_STORAGE_CYPRESS_ATACB m
396
397 IP_PNP y
398 IP_PNP_DHCP y
399 IP_PNP_BOOTP y
400 NFS_FS y
401 ROOT_NFS y
402 TUN m
403 NFS_V4 y
404 NFS_V4_1 y
405 NFS_FSCACHE y
406 NFSD m
407 NFSD_V2_ACL y
408 NFSD_V3 y
409 NFSD_V3_ACL y
410 NFSD_V4 y
411
412 # Fail to build
413 DRM n
414 SCSI_ADVANSYS n
415 USB_ISP1362_HCD n
416 SND_SOC n
417 SND_ALI5451 n
418 FB_SAVAGE n
419 SCSI_NSP32 n
420 ATA_SFF n
421 SUNGEM n
422 IRDA n
423 ATM_HE n
424 SCSI_ACARD n
425 BLK_DEV_CMD640_ENHANCED n
426
427 FUSE_FS m
428
429 # Needed for udev >= 150
430 SYSFS_DEPRECATED_V2 n
431
432 VGA_CONSOLE n
433 VT_HW_CONSOLE_BINDING y
434 SERIAL_8250_CONSOLE y
435 FRAMEBUFFER_CONSOLE y
436 EXT2_FS y
437 EXT3_FS y
438 REISERFS_FS y
439 MAGIC_SYSRQ y
440
441 # The kernel doesn't boot at all, with FTRACE
442 FTRACE n
443 '';
444 kernelTarget = "vmlinux";
445 gcc = {
446 arch = "loongson2f";
447 float = "hard";
448 abi = "n32";
449 };
450 };
451
452 ##
453 ## Other
454 ##
455
456 riscv-multiplatform = bits: {
457 name = "riscv-multiplatform";
458 kernelArch = "riscv";
459 bfdEmulation = "elf${bits}lriscv";
460 kernelTarget = "vmlinux";
461 kernelAutoModules = true;
462 kernelBaseConfig = "defconfig";
463 kernelExtraConfig = ''
464 FTRACE n
465 SERIAL_OF_PLATFORM y
466 '';
467 };
468
469 selectBySystem = system: {
470 "i686-linux" = pc32;
471 "x86_64-linux" = pc64;
472 "armv5tel-linux" = sheevaplug;
473 "armv6l-linux" = raspberrypi;
474 "armv7l-linux" = armv7l-hf-multiplatform;
475 "aarch64-linux" = aarch64-multiplatform;
476 "mipsel-linux" = fuloong2f_n32;
477 "powerpc64le-linux" = powernv;
478 }.${system} or pcBase;
479}