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