at master 15 kB view raw
1# Note: lib/systems/default.nix takes care of producing valid, 2# fully-formed "platform" values (e.g. hostPlatform, buildPlatform, 3# targetPlatform, etc) containing at least the minimal set of attrs 4# required (see types.parsedPlatform in lib/systems/parse.nix). This 5# file takes an already-valid platform and further elaborates it with 6# optional fields; currently these are: linux-kernel, gcc, and rustc. 7 8{ lib }: 9rec { 10 pc = { 11 linux-kernel = { 12 name = "pc"; 13 14 baseConfig = "defconfig"; 15 # Build whatever possible as a module, if not stated in the extra config. 16 autoModules = true; 17 target = "bzImage"; 18 }; 19 }; 20 21 pc_simplekernel = lib.recursiveUpdate pc { 22 linux-kernel.autoModules = false; 23 }; 24 25 powernv = { 26 linux-kernel = { 27 name = "PowerNV"; 28 29 baseConfig = "powernv_defconfig"; 30 target = "vmlinux"; 31 autoModules = true; 32 # avoid driver/FS trouble arising from unusual page size 33 extraConfig = '' 34 PPC_64K_PAGES n 35 PPC_4K_PAGES y 36 IPV6 y 37 38 ATA_BMDMA y 39 ATA_SFF y 40 VIRTIO_MENU y 41 ''; 42 }; 43 }; 44 45 ## 46 ## ARM 47 ## 48 49 pogoplug4 = { 50 linux-kernel = { 51 name = "pogoplug4"; 52 53 baseConfig = "multi_v5_defconfig"; 54 autoModules = false; 55 extraConfig = '' 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 makeFlags = [ "LOADADDR=0x8000" ]; 66 target = "uImage"; 67 # TODO reenable once manual-config's config actually builds a .dtb and this is checked to be working 68 #DTB = true; 69 }; 70 gcc = { 71 arch = "armv5te"; 72 }; 73 }; 74 75 sheevaplug = { 76 linux-kernel = { 77 name = "sheevaplug"; 78 79 baseConfig = "multi_v5_defconfig"; 80 autoModules = false; 81 extraConfig = '' 82 BLK_DEV_RAM y 83 BLK_DEV_INITRD y 84 BLK_DEV_CRYPTOLOOP m 85 BLK_DEV_DM m 86 DM_CRYPT m 87 MD y 88 REISERFS_FS m 89 BTRFS_FS m 90 XFS_FS m 91 JFS_FS m 92 EXT4_FS m 93 USB_STORAGE_CYPRESS_ATACB m 94 95 # mv cesa requires this sw fallback, for mv-sha1 96 CRYPTO_SHA1 y 97 # Fast crypto 98 CRYPTO_TWOFISH y 99 CRYPTO_TWOFISH_COMMON y 100 CRYPTO_BLOWFISH y 101 CRYPTO_BLOWFISH_COMMON y 102 103 IP_PNP y 104 IP_PNP_DHCP y 105 NFS_FS y 106 ROOT_NFS y 107 TUN m 108 NFS_V4 y 109 NFS_V4_1 y 110 NFS_FSCACHE y 111 NFSD m 112 NFSD_V2_ACL y 113 NFSD_V3 y 114 NFSD_V3_ACL y 115 NFSD_V4 y 116 NETFILTER y 117 IP_NF_IPTABLES y 118 IP_NF_FILTER y 119 IP_NF_MATCH_ADDRTYPE y 120 IP_NF_TARGET_LOG y 121 IP_NF_MANGLE y 122 IPV6 m 123 VLAN_8021Q m 124 125 CIFS y 126 CIFS_XATTR y 127 CIFS_POSIX y 128 CIFS_FSCACHE y 129 CIFS_ACL y 130 131 WATCHDOG y 132 WATCHDOG_CORE y 133 ORION_WATCHDOG m 134 135 ZRAM m 136 NETCONSOLE m 137 138 # Disable OABI to have seccomp_filter (required for systemd) 139 # https://github.com/raspberrypi/firmware/issues/651 140 OABI_COMPAT n 141 142 # Fail to build 143 DRM n 144 SCSI_ADVANSYS n 145 USB_ISP1362_HCD n 146 SND_SOC n 147 SND_ALI5451 n 148 FB_SAVAGE n 149 SCSI_NSP32 n 150 ATA_SFF n 151 SUNGEM n 152 IRDA n 153 ATM_HE n 154 SCSI_ACARD n 155 BLK_DEV_CMD640_ENHANCED n 156 157 FUSE_FS m 158 159 # systemd uses cgroups 160 CGROUPS y 161 162 # Latencytop 163 LATENCYTOP y 164 165 # Ubi for the mtd 166 MTD_UBI y 167 UBIFS_FS y 168 UBIFS_FS_XATTR y 169 UBIFS_FS_ADVANCED_COMPR y 170 UBIFS_FS_LZO y 171 UBIFS_FS_ZLIB y 172 UBIFS_FS_DEBUG n 173 174 # Kdb, for kernel troubles 175 KGDB y 176 KGDB_SERIAL_CONSOLE y 177 KGDB_KDB y 178 ''; 179 makeFlags = [ "LOADADDR=0x0200000" ]; 180 target = "uImage"; 181 DTB = true; # Beyond 3.10 182 }; 183 gcc = { 184 arch = "armv5te"; 185 }; 186 }; 187 188 raspberrypi = { 189 linux-kernel = { 190 name = "raspberrypi"; 191 192 baseConfig = "bcm2835_defconfig"; 193 DTB = true; 194 autoModules = true; 195 preferBuiltin = true; 196 extraConfig = '' 197 # Disable OABI to have seccomp_filter (required for systemd) 198 # https://github.com/raspberrypi/firmware/issues/651 199 OABI_COMPAT n 200 ''; 201 target = "zImage"; 202 }; 203 gcc = { 204 # https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications 205 arch = "armv6kz"; 206 fpu = "vfpv2"; 207 }; 208 }; 209 210 # Legacy attribute, for compatibility with existing configs only. 211 raspberrypi2 = armv7l-hf-multiplatform; 212 213 # Nvidia Bluefield 2 (w. crypto support) 214 bluefield2 = { 215 gcc = { 216 arch = "armv8-a+fp+simd+crc+crypto"; 217 }; 218 }; 219 220 zero-gravitas = { 221 linux-kernel = { 222 name = "zero-gravitas"; 223 224 baseConfig = "zero-gravitas_defconfig"; 225 # Target verified by checking /boot on reMarkable 1 device 226 target = "zImage"; 227 autoModules = false; 228 DTB = true; 229 }; 230 gcc = { 231 fpu = "neon"; 232 cpu = "cortex-a9"; 233 }; 234 }; 235 236 zero-sugar = { 237 linux-kernel = { 238 name = "zero-sugar"; 239 240 baseConfig = "zero-sugar_defconfig"; 241 DTB = true; 242 autoModules = false; 243 preferBuiltin = true; 244 target = "zImage"; 245 }; 246 gcc = { 247 cpu = "cortex-a7"; 248 fpu = "neon-vfpv4"; 249 float-abi = "hard"; 250 }; 251 }; 252 253 utilite = { 254 linux-kernel = { 255 name = "utilite"; 256 maseConfig = "multi_v7_defconfig"; 257 autoModules = false; 258 extraConfig = '' 259 # Ubi for the mtd 260 MTD_UBI y 261 UBIFS_FS y 262 UBIFS_FS_XATTR y 263 UBIFS_FS_ADVANCED_COMPR y 264 UBIFS_FS_LZO y 265 UBIFS_FS_ZLIB y 266 UBIFS_FS_DEBUG n 267 ''; 268 makeFlags = [ "LOADADDR=0x10800000" ]; 269 target = "uImage"; 270 DTB = true; 271 }; 272 gcc = { 273 cpu = "cortex-a9"; 274 fpu = "neon"; 275 }; 276 }; 277 278 guruplug = lib.recursiveUpdate sheevaplug { 279 # Define `CONFIG_MACH_GURUPLUG' (see 280 # <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>) 281 # and other GuruPlug-specific things. Requires the `guruplug-defconfig' 282 # patch. 283 linux-kernel.baseConfig = "guruplug_defconfig"; 284 }; 285 286 beaglebone = lib.recursiveUpdate armv7l-hf-multiplatform { 287 linux-kernel = { 288 name = "beaglebone"; 289 baseConfig = "bb.org_defconfig"; 290 autoModules = false; 291 extraConfig = ""; # TBD kernel config 292 target = "zImage"; 293 }; 294 }; 295 296 # https://developer.android.com/ndk/guides/abis#v7a 297 armv7a-android = { 298 linux-kernel.name = "armeabi-v7a"; 299 gcc = { 300 arch = "armv7-a"; 301 float-abi = "softfp"; 302 fpu = "vfpv3-d16"; 303 }; 304 }; 305 306 armv7l-hf-multiplatform = { 307 linux-kernel = { 308 name = "armv7l-hf-multiplatform"; 309 Major = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc. 310 baseConfig = "multi_v7_defconfig"; 311 DTB = true; 312 autoModules = true; 313 preferBuiltin = true; 314 target = "zImage"; 315 extraConfig = '' 316 # Serial port for Raspberry Pi 3. Wasn't included in ARMv7 defconfig 317 # until 4.17. 318 SERIAL_8250_BCM2835AUX y 319 SERIAL_8250_EXTENDED y 320 SERIAL_8250_SHARE_IRQ y 321 322 # Hangs ODROID-XU4 323 ARM_BIG_LITTLE_CPUIDLE n 324 325 # Disable OABI to have seccomp_filter (required for systemd) 326 # https://github.com/raspberrypi/firmware/issues/651 327 OABI_COMPAT n 328 329 # >=5.12 fails with: 330 # drivers/net/ethernet/micrel/ks8851_common.o: in function `ks8851_probe_common': 331 # ks8851_common.c:(.text+0x179c): undefined reference to `__this_module' 332 # See: https://lore.kernel.org/netdev/20210116164828.40545-1-marex@denx.de/T/ 333 KS8851_MLL y 334 ''; 335 }; 336 gcc = { 337 # Some table about fpu flags: 338 # http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png 339 # Cortex-A5: -mfpu=neon-fp16 340 # Cortex-A7 (rpi2): -mfpu=neon-vfpv4 341 # Cortex-A8 (beaglebone): -mfpu=neon 342 # Cortex-A9: -mfpu=neon-fp16 343 # Cortex-A15: -mfpu=neon-vfpv4 344 345 # More about FPU: 346 # https://wiki.debian.org/ArmHardFloatPort/VfpComparison 347 348 # vfpv3-d16 is what Debian uses and seems to be the best compromise: NEON is not supported in e.g. Scaleway or Tegra 2, 349 # and the above page suggests NEON is only an improvement with hand-written assembly. 350 arch = "armv7-a"; 351 fpu = "vfpv3-d16"; 352 353 # For Raspberry Pi the 2 the best would be: 354 # cpu = "cortex-a7"; 355 # fpu = "neon-vfpv4"; 356 }; 357 }; 358 359 aarch64-multiplatform = { 360 linux-kernel = { 361 name = "aarch64-multiplatform"; 362 baseConfig = "defconfig"; 363 DTB = true; 364 autoModules = true; 365 preferBuiltin = true; 366 extraConfig = '' 367 # Raspberry Pi 3 stuff. Not needed for s >= 4.10. 368 ARCH_BCM2835 y 369 BCM2835_MBOX y 370 BCM2835_WDT y 371 RASPBERRYPI_FIRMWARE y 372 RASPBERRYPI_POWER y 373 SERIAL_8250_BCM2835AUX y 374 SERIAL_8250_EXTENDED y 375 SERIAL_8250_SHARE_IRQ y 376 377 # Cavium ThunderX stuff. 378 PCI_HOST_THUNDER_ECAM y 379 380 # Nvidia Tegra stuff. 381 PCI_TEGRA y 382 383 # The default (=y) forces us to have the XHCI firmware available in initrd, 384 # which our initrd builder can't currently do easily. 385 USB_XHCI_TEGRA m 386 ''; 387 target = "Image"; 388 }; 389 gcc = { 390 arch = "armv8-a"; 391 }; 392 }; 393 394 apple-m1 = { 395 gcc = { 396 arch = "armv8.3-a+crypto+sha2+aes+crc+fp16+lse+simd+ras+rdm+rcpc"; 397 cpu = "apple-a13"; 398 }; 399 }; 400 401 ## 402 ## MIPS 403 ## 404 405 ben_nanonote = { 406 linux-kernel = { 407 name = "ben_nanonote"; 408 }; 409 gcc = { 410 arch = "mips32"; 411 float = "soft"; 412 }; 413 }; 414 415 fuloong2f_n32 = { 416 linux-kernel = { 417 name = "fuloong2f_n32"; 418 baseConfig = "lemote2f_defconfig"; 419 autoModules = false; 420 extraConfig = '' 421 MIGRATION n 422 COMPACTION n 423 424 # nixos mounts some cgroup 425 CGROUPS y 426 427 BLK_DEV_RAM y 428 BLK_DEV_INITRD y 429 BLK_DEV_CRYPTOLOOP m 430 BLK_DEV_DM m 431 DM_CRYPT m 432 MD y 433 REISERFS_FS m 434 EXT4_FS m 435 USB_STORAGE_CYPRESS_ATACB m 436 437 IP_PNP y 438 IP_PNP_DHCP y 439 IP_PNP_BOOTP y 440 NFS_FS y 441 ROOT_NFS y 442 TUN m 443 NFS_V4 y 444 NFS_V4_1 y 445 NFS_FSCACHE y 446 NFSD m 447 NFSD_V2_ACL y 448 NFSD_V3 y 449 NFSD_V3_ACL y 450 NFSD_V4 y 451 452 # Fail to build 453 DRM n 454 SCSI_ADVANSYS n 455 USB_ISP1362_HCD n 456 SND_SOC n 457 SND_ALI5451 n 458 FB_SAVAGE n 459 SCSI_NSP32 n 460 ATA_SFF n 461 SUNGEM n 462 IRDA n 463 ATM_HE n 464 SCSI_ACARD n 465 BLK_DEV_CMD640_ENHANCED n 466 467 FUSE_FS m 468 469 # Needed for udev >= 150 470 SYSFS_DEPRECATED_V2 n 471 472 VGA_CONSOLE n 473 VT_HW_CONSOLE_BINDING y 474 SERIAL_8250_CONSOLE y 475 FRAMEBUFFER_CONSOLE y 476 EXT2_FS y 477 EXT3_FS y 478 REISERFS_FS y 479 MAGIC_SYSRQ y 480 481 # The kernel doesn't boot at all, with FTRACE 482 FTRACE n 483 ''; 484 target = "vmlinux"; 485 }; 486 gcc = { 487 arch = "loongson2f"; 488 float = "hard"; 489 abi = "n32"; 490 }; 491 }; 492 493 # can execute on 32bit chip 494 gcc_mips32r2_o32 = { 495 gcc = { 496 arch = "mips32r2"; 497 abi = "32"; 498 }; 499 }; 500 gcc_mips32r6_o32 = { 501 gcc = { 502 arch = "mips32r6"; 503 abi = "32"; 504 }; 505 }; 506 gcc_mips64r2_n32 = { 507 gcc = { 508 arch = "mips64r2"; 509 abi = "n32"; 510 }; 511 }; 512 gcc_mips64r6_n32 = { 513 gcc = { 514 arch = "mips64r6"; 515 abi = "n32"; 516 }; 517 }; 518 gcc_mips64r2_64 = { 519 gcc = { 520 arch = "mips64r2"; 521 abi = "64"; 522 }; 523 }; 524 gcc_mips64r6_64 = { 525 gcc = { 526 arch = "mips64r6"; 527 abi = "64"; 528 }; 529 }; 530 531 # based on: 532 # https://www.mail-archive.com/qemu-discuss@nongnu.org/msg05179.html 533 # https://gmplib.org/~tege/qemu.html#mips64-debian 534 mips64el-qemu-linux-gnuabi64 = { 535 linux-kernel = { 536 name = "mips64el"; 537 baseConfig = "64r2el_defconfig"; 538 target = "vmlinuz"; 539 autoModules = false; 540 DTB = true; 541 # for qemu 9p passthrough filesystem 542 extraConfig = '' 543 MIPS_MALTA y 544 PAGE_SIZE_4KB y 545 CPU_LITTLE_ENDIAN y 546 CPU_MIPS64_R2 y 547 64BIT y 548 CPU_MIPS64_R2 y 549 550 NET_9P y 551 NET_9P_VIRTIO y 552 9P_FS y 553 9P_FS_POSIX_ACL y 554 PCI y 555 VIRTIO_PCI y 556 ''; 557 }; 558 }; 559 560 ## 561 ## Other 562 ## 563 564 riscv-multiplatform = { 565 linux-kernel = { 566 name = "riscv-multiplatform"; 567 target = "Image"; 568 autoModules = true; 569 preferBuiltin = true; 570 baseConfig = "defconfig"; 571 DTB = true; 572 }; 573 }; 574 575 loongarch64-multiplatform = { 576 gcc = { 577 # https://github.com/loongson/la-softdev-convention/blob/master/la-softdev-convention.adoc#10-operating-system-package-build-requirements 578 arch = "la64v1.0"; 579 strict-align = false; 580 # Avoid text sections of large apps exceeding default code model 581 # Will be default behavior in LLVM 21 and hopefully GCC16 582 # https://github.com/loongson-community/discussions/issues/43 583 # https://github.com/llvm/llvm-project/pull/132173 584 cmodel = "medium"; 585 }; 586 linux-kernel = { 587 name = "loongarch-multiplatform"; 588 target = "vmlinuz.efi"; 589 autoModules = true; 590 preferBuiltin = true; 591 baseConfig = "defconfig"; 592 DTB = true; 593 }; 594 }; 595 596 # This function takes a minimally-valid "platform" and returns an 597 # attrset containing zero or more additional attrs which should be 598 # included in the platform in order to further elaborate it. 599 select = 600 platform: 601 # x86 602 if platform.isx86 then 603 pc 604 605 # ARM 606 else if platform.isAarch32 then 607 let 608 version = platform.parsed.cpu.version or null; 609 in 610 if version == null then 611 pc 612 else if lib.versionOlder version "6" then 613 sheevaplug 614 else if lib.versionOlder version "7" then 615 raspberrypi 616 else 617 armv7l-hf-multiplatform 618 619 else if platform.isAarch64 then 620 if platform.isDarwin then apple-m1 else aarch64-multiplatform 621 622 else if platform.isLoongArch64 then 623 loongarch64-multiplatform 624 625 else if platform.isRiscV then 626 riscv-multiplatform 627 628 else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then 629 (import ./examples.nix { inherit lib; }).mipsel-linux-gnu 630 631 else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then 632 powernv 633 634 else if platform.isLoongArch64 then 635 loongarch64-multiplatform 636 else 637 { }; 638}