at 24.11-pre 14 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 arch = "armv6"; 205 fpu = "vfp"; 206 }; 207 }; 208 209 # Legacy attribute, for compatibility with existing configs only. 210 raspberrypi2 = armv7l-hf-multiplatform; 211 212 # Nvidia Bluefield 2 (w. crypto support) 213 bluefield2 = { 214 gcc = { 215 arch = "armv8-a+fp+simd+crc+crypto"; 216 }; 217 }; 218 219 zero-gravitas = { 220 linux-kernel = { 221 name = "zero-gravitas"; 222 223 baseConfig = "zero-gravitas_defconfig"; 224 # Target verified by checking /boot on reMarkable 1 device 225 target = "zImage"; 226 autoModules = false; 227 DTB = true; 228 }; 229 gcc = { 230 fpu = "neon"; 231 cpu = "cortex-a9"; 232 }; 233 }; 234 235 zero-sugar = { 236 linux-kernel = { 237 name = "zero-sugar"; 238 239 baseConfig = "zero-sugar_defconfig"; 240 DTB = true; 241 autoModules = false; 242 preferBuiltin = true; 243 target = "zImage"; 244 }; 245 gcc = { 246 cpu = "cortex-a7"; 247 fpu = "neon-vfpv4"; 248 float-abi = "hard"; 249 }; 250 }; 251 252 utilite = { 253 linux-kernel = { 254 name = "utilite"; 255 maseConfig = "multi_v7_defconfig"; 256 autoModules = false; 257 extraConfig = '' 258 # Ubi for the mtd 259 MTD_UBI y 260 UBIFS_FS y 261 UBIFS_FS_XATTR y 262 UBIFS_FS_ADVANCED_COMPR y 263 UBIFS_FS_LZO y 264 UBIFS_FS_ZLIB y 265 UBIFS_FS_DEBUG n 266 ''; 267 makeFlags = [ "LOADADDR=0x10800000" ]; 268 target = "uImage"; 269 DTB = true; 270 }; 271 gcc = { 272 cpu = "cortex-a9"; 273 fpu = "neon"; 274 }; 275 }; 276 277 guruplug = lib.recursiveUpdate sheevaplug { 278 # Define `CONFIG_MACH_GURUPLUG' (see 279 # <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>) 280 # and other GuruPlug-specific things. Requires the `guruplug-defconfig' 281 # patch. 282 linux-kernel.baseConfig = "guruplug_defconfig"; 283 }; 284 285 beaglebone = lib.recursiveUpdate armv7l-hf-multiplatform { 286 linux-kernel = { 287 name = "beaglebone"; 288 baseConfig = "bb.org_defconfig"; 289 autoModules = false; 290 extraConfig = ""; # TBD kernel config 291 target = "zImage"; 292 }; 293 }; 294 295 # https://developer.android.com/ndk/guides/abis#v7a 296 armv7a-android = { 297 linux-kernel.name = "armeabi-v7a"; 298 gcc = { 299 arch = "armv7-a"; 300 float-abi = "softfp"; 301 fpu = "vfpv3-d16"; 302 }; 303 }; 304 305 armv7l-hf-multiplatform = { 306 linux-kernel = { 307 name = "armv7l-hf-multiplatform"; 308 Major = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc. 309 baseConfig = "multi_v7_defconfig"; 310 DTB = true; 311 autoModules = true; 312 preferBuiltin = true; 313 target = "zImage"; 314 extraConfig = '' 315 # Serial port for Raspberry Pi 3. Wasn't included in ARMv7 defconfig 316 # until 4.17. 317 SERIAL_8250_BCM2835AUX y 318 SERIAL_8250_EXTENDED y 319 SERIAL_8250_SHARE_IRQ y 320 321 # Hangs ODROID-XU4 322 ARM_BIG_LITTLE_CPUIDLE n 323 324 # Disable OABI to have seccomp_filter (required for systemd) 325 # https://github.com/raspberrypi/firmware/issues/651 326 OABI_COMPAT n 327 328 # >=5.12 fails with: 329 # drivers/net/ethernet/micrel/ks8851_common.o: in function `ks8851_probe_common': 330 # ks8851_common.c:(.text+0x179c): undefined reference to `__this_module' 331 # See: https://lore.kernel.org/netdev/20210116164828.40545-1-marex@denx.de/T/ 332 KS8851_MLL y 333 ''; 334 }; 335 gcc = { 336 # Some table about fpu flags: 337 # http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png 338 # Cortex-A5: -mfpu=neon-fp16 339 # Cortex-A7 (rpi2): -mfpu=neon-vfpv4 340 # Cortex-A8 (beaglebone): -mfpu=neon 341 # Cortex-A9: -mfpu=neon-fp16 342 # Cortex-A15: -mfpu=neon-vfpv4 343 344 # More about FPU: 345 # https://wiki.debian.org/ArmHardFloatPort/VfpComparison 346 347 # vfpv3-d16 is what Debian uses and seems to be the best compromise: NEON is not supported in e.g. Scaleway or Tegra 2, 348 # and the above page suggests NEON is only an improvement with hand-written assembly. 349 arch = "armv7-a"; 350 fpu = "vfpv3-d16"; 351 352 # For Raspberry Pi the 2 the best would be: 353 # cpu = "cortex-a7"; 354 # fpu = "neon-vfpv4"; 355 }; 356 }; 357 358 aarch64-multiplatform = { 359 linux-kernel = { 360 name = "aarch64-multiplatform"; 361 baseConfig = "defconfig"; 362 DTB = true; 363 autoModules = true; 364 preferBuiltin = true; 365 extraConfig = '' 366 # Raspberry Pi 3 stuff. Not needed for s >= 4.10. 367 ARCH_BCM2835 y 368 BCM2835_MBOX y 369 BCM2835_WDT y 370 RASPBERRYPI_FIRMWARE y 371 RASPBERRYPI_POWER y 372 SERIAL_8250_BCM2835AUX y 373 SERIAL_8250_EXTENDED y 374 SERIAL_8250_SHARE_IRQ y 375 376 # Cavium ThunderX stuff. 377 PCI_HOST_THUNDER_ECAM y 378 379 # Nvidia Tegra stuff. 380 PCI_TEGRA y 381 382 # The default (=y) forces us to have the XHCI firmware available in initrd, 383 # which our initrd builder can't currently do easily. 384 USB_XHCI_TEGRA m 385 ''; 386 target = "Image"; 387 }; 388 gcc = { 389 arch = "armv8-a"; 390 }; 391 }; 392 393 apple-m1 = { 394 gcc = { 395 arch = "armv8.3-a+crypto+sha2+aes+crc+fp16+lse+simd+ras+rdm+rcpc"; 396 cpu = "apple-a13"; 397 }; 398 }; 399 400 ## 401 ## MIPS 402 ## 403 404 ben_nanonote = { 405 linux-kernel = { 406 name = "ben_nanonote"; 407 }; 408 gcc = { 409 arch = "mips32"; 410 float = "soft"; 411 }; 412 }; 413 414 fuloong2f_n32 = { 415 linux-kernel = { 416 name = "fuloong2f_n32"; 417 baseConfig = "lemote2f_defconfig"; 418 autoModules = false; 419 extraConfig = '' 420 MIGRATION n 421 COMPACTION n 422 423 # nixos mounts some cgroup 424 CGROUPS y 425 426 BLK_DEV_RAM y 427 BLK_DEV_INITRD y 428 BLK_DEV_CRYPTOLOOP m 429 BLK_DEV_DM m 430 DM_CRYPT m 431 MD y 432 REISERFS_FS m 433 EXT4_FS m 434 USB_STORAGE_CYPRESS_ATACB m 435 436 IP_PNP y 437 IP_PNP_DHCP y 438 IP_PNP_BOOTP y 439 NFS_FS y 440 ROOT_NFS y 441 TUN m 442 NFS_V4 y 443 NFS_V4_1 y 444 NFS_FSCACHE y 445 NFSD m 446 NFSD_V2_ACL y 447 NFSD_V3 y 448 NFSD_V3_ACL y 449 NFSD_V4 y 450 451 # Fail to build 452 DRM n 453 SCSI_ADVANSYS n 454 USB_ISP1362_HCD n 455 SND_SOC n 456 SND_ALI5451 n 457 FB_SAVAGE n 458 SCSI_NSP32 n 459 ATA_SFF n 460 SUNGEM n 461 IRDA n 462 ATM_HE n 463 SCSI_ACARD n 464 BLK_DEV_CMD640_ENHANCED n 465 466 FUSE_FS m 467 468 # Needed for udev >= 150 469 SYSFS_DEPRECATED_V2 n 470 471 VGA_CONSOLE n 472 VT_HW_CONSOLE_BINDING y 473 SERIAL_8250_CONSOLE y 474 FRAMEBUFFER_CONSOLE y 475 EXT2_FS y 476 EXT3_FS y 477 REISERFS_FS y 478 MAGIC_SYSRQ y 479 480 # The kernel doesn't boot at all, with FTRACE 481 FTRACE n 482 ''; 483 target = "vmlinux"; 484 }; 485 gcc = { 486 arch = "loongson2f"; 487 float = "hard"; 488 abi = "n32"; 489 }; 490 }; 491 492 # can execute on 32bit chip 493 gcc_mips32r2_o32 = { gcc = { arch = "mips32r2"; abi = "32"; }; }; 494 gcc_mips32r6_o32 = { gcc = { arch = "mips32r6"; abi = "32"; }; }; 495 gcc_mips64r2_n32 = { gcc = { arch = "mips64r2"; abi = "n32"; }; }; 496 gcc_mips64r6_n32 = { gcc = { arch = "mips64r6"; abi = "n32"; }; }; 497 gcc_mips64r2_64 = { gcc = { arch = "mips64r2"; abi = "64"; }; }; 498 gcc_mips64r6_64 = { gcc = { arch = "mips64r6"; abi = "64"; }; }; 499 500 # based on: 501 # https://www.mail-archive.com/qemu-discuss@nongnu.org/msg05179.html 502 # https://gmplib.org/~tege/qemu.html#mips64-debian 503 mips64el-qemu-linux-gnuabi64 = { 504 linux-kernel = { 505 name = "mips64el"; 506 baseConfig = "64r2el_defconfig"; 507 target = "vmlinuz"; 508 autoModules = false; 509 DTB = true; 510 # for qemu 9p passthrough filesystem 511 extraConfig = '' 512 MIPS_MALTA y 513 PAGE_SIZE_4KB y 514 CPU_LITTLE_ENDIAN y 515 CPU_MIPS64_R2 y 516 64BIT y 517 CPU_MIPS64_R2 y 518 519 NET_9P y 520 NET_9P_VIRTIO y 521 9P_FS y 522 9P_FS_POSIX_ACL y 523 PCI y 524 VIRTIO_PCI y 525 ''; 526 }; 527 }; 528 529 ## 530 ## Other 531 ## 532 533 riscv-multiplatform = { 534 linux-kernel = { 535 name = "riscv-multiplatform"; 536 target = "Image"; 537 autoModules = true; 538 baseConfig = "defconfig"; 539 DTB = true; 540 extraConfig = '' 541 SERIAL_OF_PLATFORM y 542 ''; 543 }; 544 }; 545 546 # This function takes a minimally-valid "platform" and returns an 547 # attrset containing zero or more additional attrs which should be 548 # included in the platform in order to further elaborate it. 549 select = platform: 550 # x86 551 /**/ if platform.isx86 then pc 552 553 # ARM 554 else if platform.isAarch32 then let 555 version = platform.parsed.cpu.version or null; 556 in if version == null then pc 557 else if lib.versionOlder version "6" then sheevaplug 558 else if lib.versionOlder version "7" then raspberrypi 559 else armv7l-hf-multiplatform 560 561 else if platform.isAarch64 then 562 if platform.isDarwin then apple-m1 563 else aarch64-multiplatform 564 565 else if platform.isRiscV then riscv-multiplatform 566 567 else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then (import ./examples.nix { inherit lib; }).mipsel-linux-gnu 568 569 else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv 570 571 else { }; 572}