From 3829ce4ce7664d57cebe3367d27846d8c5f865de Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 29 Oct 2023 22:21:06 -0700 Subject: [PATCH] lib.systems.inspect: deprecate isEfi This predicate never did what it claimed. (U)EFI support is a property of a specific motherboard, not of a platform or an entire architecture. This predicate was used only by two packages. This commit relocates the data previously held by `inspect.isEfi` to the `meta.platforms` of `gnu-efi` and the `withEfi` default value of `systemd`. We need to make room for `isEfi` (or perhaps `isUefi`) in preparation for https://github.com/NixOS/nixpkgs/pull/231951 so we should start the deprecation process sooner rather than later. --- lib/systems/inspect.nix | 22 ++++++++++++++++++- .../development/libraries/gnu-efi/default.nix | 4 +++- pkgs/os-specific/linux/systemd/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 4 +--- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 022e459c3945a..7a52e94acfdd1 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -6,7 +6,7 @@ with lib.lists; let abis_ = abis; in let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in -rec { +let result = rec { # these patterns are to be matched against {host,build,target}Platform.parsed patterns = rec { # The patterns below are lists in sum-of-products form. @@ -31,9 +31,11 @@ rec { ]; isx86 = { cpu = { family = "x86"; }; }; isAarch32 = { cpu = { family = "arm"; bits = 32; }; }; + isArmv6 = { cpu = { family = "arm"; version = "6"; }; }; isArmv7 = map ({ arch, ... }: { cpu = { inherit arch; }; }) (lib.filter (cpu: lib.hasPrefix "armv7" cpu.arch or "") (lib.attrValues cpuTypes)); + isArmv8 = { cpu = { family = "arm"; version = "8"; }; }; isAarch64 = { cpu = { family = "arm"; bits = 64; }; }; isAarch = { cpu = { family = "arm"; }; }; isMicroBlaze = { cpu = { family = "microblaze"; }; }; @@ -114,4 +116,22 @@ rec { platformPatterns = mapAttrs (_: p: { parsed = {}; } // p) { isStatic = { isStatic = true; }; }; +}; + +warnEfiDeprecated = throw "(U)EFI support is a feature of specific motherboards rather than entire architectures or platforms; this predicate has been deprecated because its name is misleading"; + +in +result // { + patterns = result.patterns // { + isEfi = warnEfiDeprecated result.patterns.isEfi; + }; + + # Unfortunately a strictness bug in lib.systems.equals means that + # we can't lib.warn on accesses to boolean values. If + # https://github.com/NixOS/nixpkgs/pull/238331 is merged we can go + # back to using Nix `==` and this warning can be enabled. + # + #predicates = result.predicates // { + # isEfi = argument: warnEfiDeprecated (result.predicates.isEfi argument); + #}; } diff --git a/pkgs/development/libraries/gnu-efi/default.nix b/pkgs/development/libraries/gnu-efi/default.nix index e9746271ea27e..81a8c98bd2f8a 100644 --- a/pkgs/development/libraries/gnu-efi/default.nix +++ b/pkgs/development/libraries/gnu-efi/default.nix @@ -34,7 +34,9 @@ stdenv.mkDerivation rec { description = "GNU EFI development toolchain"; homepage = "https://sourceforge.net/projects/gnu-efi/"; license = licenses.bsd3; - platforms = platforms.linux; + platforms = with lib.systems.inspect.patterns; map (pat: pat // isLinux) ([ + isArmv6 ] ++ isArmv7 ++ [ isArmv8 isRiscV isx86 + ]); maintainers = with maintainers; [ ]; }; } diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 01054fa7fc6b2..a7772abb8039e 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 ? with stdenv.hostPlatform; isArmv6 || isArmv7 || isArmv8 || isRiscV || isx86 , withFido2 ? true , withFirstboot ? false # conflicts with the NixOS /etc management , withHomed ? !stdenv.hostPlatform.isMusl @@ -756,7 +756,7 @@ stdenv.mkDerivation (finalAttrs: { # runtime; otherwise we can't and we need to reboot. interfaceVersion = 2; - inherit withCryptsetup withHostnamed withImportd withKmod withLocaled withMachined withPortabled withTimedated withUtmp util-linux kmod kbd; + inherit withCryptsetup withHostnamed withImportd withKmod withLocaled withMachined withPortabled withTimedated withUtmp util-linux kmod kbd withEfi; tests = { inherit (nixosTests) switchTest; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b0150c6bca6d9..afab46156cbd0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21804,9 +21804,7 @@ with pkgs; gnu-config = callPackage ../development/libraries/gnu-config { }; - gnu-efi = if stdenv.hostPlatform.isEfi - then callPackage ../development/libraries/gnu-efi { } - else null; + gnu-efi = callPackage ../development/libraries/gnu-efi { }; gnutls = callPackage ../development/libraries/gnutls { inherit (darwin.apple_sdk.frameworks) Security;