1 # Derivation containing the Limine host tool and the compiled bootloader
8 # The following options map to configure flags.
18 llvmPackages = llvmPackages_18;
19 stdenv = llvmPackages.stdenv;
24 (if targets == [ ] then stdenv.hostPlatform.isx86_32 else (builtins.elem "i686" targets))
28 (if targets == [ ] then stdenv.hostPlatform.isx86_64 else (builtins.elem "x86_64" targets))
34 aarch64 = [ "--enable-uefi-aarch64" ];
35 i686 = [ "--enable-uefi-ia32" ];
36 loongarch64 = [ "--enable-uefi-loongarch64" ];
37 riscv64 = [ "--enable-uefi-riscv64" ];
38 x86_64 = [ "--enable-uefi-x86-64" ];
40 .${target} or (throw "Unsupported target ${target}");
43 lib.optionals enableAll [ "--enable-all" ]
44 ++ lib.optionals biosSupport [ "--enable-bios" ]
45 ++ lib.optionals (buildCDs && biosSupport) [ "--enable-bios-cd" ]
46 ++ lib.optionals buildCDs [ "--enable-uefi-cd" ]
47 ++ lib.optionals pxeSupport [ "--enable-bios-pxe" ]
48 ++ lib.concatMap uefiFlags (
49 if targets == [ ] then [ stdenv.hostPlatform.parsed.cpu.name ] else targets
53 assert lib.assertMsg (!(biosSupport && !hasI686)) "BIOS builds are possible only for x86";
55 assert lib.assertMsg (!(pxeSupport && !hasI686)) "PXE builds are possible only for x86";
57 # The output of the derivation is a tool to create bootable images using Limine
58 # as bootloader for various platforms and corresponding binary and helper files.
60 inherit version configureFlags;
62 # We don't use the Git source but the release tarball, as the source has a
63 # `./bootstrap` script performing network access to download resources.
64 # Packaging that in Nix is very cumbersome.
66 url = "https://github.com/limine-bootloader/limine/releases/download/v${version}/limine-${version}.tar.gz";
67 hash = "sha256-pwoR9ptMpdhdEe/Kbyc+smv9oNIqtJ9L0KFdf6/g0Ec=";
71 # clang doesn't support this for RISC-V target
75 enableParallelBuilding = true;
82 ++ lib.optionals (enableAll || buildCDs) [
85 ++ lib.optionals (hasI686 || hasX86_64) [ nasm ];
95 homepage = "https://limine-bootloader.org/";
96 description = "Limine Bootloader";
97 mainProgram = "limine";
98 # The platforms on that the Limine binary and helper tools can run, not
99 # necessarily the platforms for that bootable images can be created.
100 platforms = platforms.unix;
101 badPlatforms = platforms.darwin;
102 # Caution. Some submodules have different licenses.
104 licenses.asl20 # cc-runtime
105 licenses.bsd0 # freestanding-toolchain, freestanding-headers
106 licenses.bsd2 # limine, flanterm
107 licenses.mit # limine-efi, stb
114 maintainers.surfaceflinger