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