diff --git a/doc/stdenv/platform-notes.chapter.md b/doc/stdenv/platform-notes.chapter.md index b47f5af349b8d..874de9a2f912d 100644 --- a/doc/stdenv/platform-notes.chapter.md +++ b/doc/stdenv/platform-notes.chapter.md @@ -1,5 +1,19 @@ # Platform Notes {#chap-platform-notes} +## UEFI {#sec-uefi} + +Some common issues when packaging software for UEFI environments: + +- Not all compilers know about UEFI as a proper target. + + Most software will offer ways to compile UEFI software as it was compiled for the host system (not the UEFI host system) which will either confuse nixpkgs, you, or will be a hack. + + Examples of such software are GNU GRUB (GNU-EFI), systemd-boot (elf2efi) and EDK2 firmware (bespoke build scripts) + +- Nixpkgs cannot know if you have UEFI firmware support or not on your platform beyond what is declared to be supported. + + Use `pkgs.stdenv.hostPlatform.hasEfi` to know if it potentially have any form of UEFI support. + ## Darwin (macOS) {#sec-darwin} Some common issues when packaging software for Darwin: diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 022e459c3945a..b6e0ab3756bd0 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -91,13 +91,19 @@ rec { isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf muslabin32 muslabi64 ]; isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ]; - isEfi = [ + # This is the list of platforms which can potentially have a UEFI firmware + # This is helpful to know when to emit UEFI binaries along your software, e.g. for boot or more. + hasEfi = [ { cpu = { family = "arm"; version = "6"; }; } { cpu = { family = "arm"; version = "7"; }; } { cpu = { family = "arm"; version = "8"; }; } { cpu = { family = "riscv"; }; } { cpu = { family = "x86"; }; } ]; + + # This name will soon be used for detection of the UEFI target itself. + # Start deprecation of this in NixOS 24.05 + isEfi = hasEfi; }; matchAnyAttrs = patterns: diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 01054fa7fc6b2..d63b6389e7b05 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -94,7 +94,7 @@ , withCryptsetup ? true , withRepart ? true , withDocumentation ? true -, withEfi ? stdenv.hostPlatform.isEfi +, withEfi ? stdenv.hostPlatform.hasEfi , withFido2 ? true , withFirstboot ? false # conflicts with the NixOS /etc management , withHomed ? !stdenv.hostPlatform.isMusl diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 58b491bad3efc..1601ab188b984 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21796,7 +21796,7 @@ with pkgs; gnu-config = callPackage ../development/libraries/gnu-config { }; - gnu-efi = if stdenv.hostPlatform.isEfi + gnu-efi = if stdenv.hostPlatform.hasEfi then callPackage ../development/libraries/gnu-efi { } else null;