From c0085404bd9dd6721eed9b6a5a36a310ca31b286 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 10 Apr 2022 01:59:20 -0700 Subject: [PATCH] lib/systems/inspect.nix: remove isPowerPC Very confusingly, the `isPowerPC` predicate in `lib/systems/inspect.nix` does *not* match `powerpc64le`! This is because `isPowerPC` is defined as isPowerPC = { cpu = cpuTypes.powerpc; }; Where `cpuTypes.powerpc` is: { bits = 32; significantByte = bigEndian; family = "power"; }; This means that the `isPowerPC` predicate actually only matches the subset of machines marketed under this name which happen to be 32-bit and running in big-endian mode which is equivalent to: with stdenv.hostPlatform; isPower && isBigEndian && is32bit This seems like a sharp edge that people could easily cut themselves on. In fact, that has already happened: in `linux/kernel/common-config.nix` there is a test which will always fail: (stdenv.hostPlatform.isPowerPC && stdenv.hostPlatform.is64bit) A more subtle case of the strict isPowerPC being used instead of the moreg general isPower accidentally are the GHC expressions: Update pkgs/development/compilers/ghc/8.10.7.nix Update pkgs/development/compilers/ghc/8.8.4.nix Update pkgs/development/compilers/ghc/9.2.2.nix Update pkgs/development/compilers/ghc/9.0.2.nix Update pkgs/development/compilers/ghc/head.nix Since the remaining legitimate use sites of isPowerPC are so few, remove the isPowerPC predicate completely. The alternative expression above is noted in the release notes as an alternative. Co-authored-by: sternenseemann --- lib/systems/inspect.nix | 1 - .../from_md/release-notes/rl-2211.section.xml | 17 ++++++++++++++++- .../doc/manual/release-notes/rl-2211.section.md | 3 +++ nixos/modules/installer/cd-dvd/iso-image.nix | 2 +- pkgs/development/compilers/ghc/8.10.7.nix | 2 +- pkgs/development/compilers/ghc/8.8.4.nix | 2 +- pkgs/development/compilers/ghc/9.0.2.nix | 2 +- pkgs/development/compilers/ghc/9.2.2.nix | 2 +- pkgs/development/compilers/ghc/head.nix | 2 +- .../linux/kernel-headers/default.nix | 2 +- pkgs/os-specific/linux/kernel/common-config.nix | 2 +- 11 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 00cbe4f012cb..e5bd879e2c42 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -11,7 +11,6 @@ rec { isi686 = { cpu = cpuTypes.i686; }; isx86_32 = { cpu = { family = "x86"; bits = 32; }; }; isx86_64 = { cpu = { family = "x86"; bits = 64; }; }; - isPowerPC = { cpu = cpuTypes.powerpc; }; isPower = { cpu = { family = "power"; }; }; isPower64 = { cpu = { family = "power"; bits = 64; }; }; isx86 = { cpu = { family = "x86"; }; }; diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml index 79268b398e60..908d1ab46e8f 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml @@ -51,7 +51,7 @@
Backward Incompatibilities - + The isCompatible predicate checking CPU @@ -69,6 +69,21 @@ compatible. + + + The isPowerPC predicate, found on + platform attrsets + (hostPlatform, + buildPlatform, + targetPlatform, etc) has been removed in + order to reduce confusion. The predicate was was defined such + that it matches only the 32-bit big-endian members of the + POWER/PowerPC family, despite having a name which would imply + a broader set of systems. If you were using this predicate, + you can replace foo.isPowerPC with + (with foo; isPower && is32bit && isBigEndian). + +
diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md index 7d2eacce57fe..87fdf4e77f25 100644 --- a/nixos/doc/manual/release-notes/rl-2211.section.md +++ b/nixos/doc/manual/release-notes/rl-2211.section.md @@ -37,6 +37,9 @@ In addition to numerous new and upgraded packages, this release has the followin `lib.systems.parse.isCompatible` still exists, but has changed semantically: Architectures with differing endianness modes are *no longer considered compatible*. +- The `isPowerPC` predicate, found on `platform` attrsets (`hostPlatform`, `buildPlatform`, `targetPlatform`, etc) has been removed in order to reduce confusion. The predicate was was defined such that it matches only the 32-bit big-endian members of the POWER/PowerPC family, despite having a name which would imply a broader set of systems. If you were using this predicate, you can replace `foo.isPowerPC` with `(with foo; isPower && is32bit && isBigEndian)`. + + ## Other Notable Changes {#sec-release-22.11-notable-changes} diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index 1eaa940afb1f..d1ccc6c2072f 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -479,7 +479,7 @@ in + lib.optionalString (isx86_32 || isx86_64) "-Xbcj x86" # Untested but should also reduce size for these platforms + lib.optionalString (isAarch32 || isAarch64) "-Xbcj arm" - + lib.optionalString (isPowerPC) "-Xbcj powerpc" + + lib.optionalString (isPower && is32bit && isBigEndian) "-Xbcj powerpc" + lib.optionalString (isSparc) "-Xbcj sparc"; description = '' Compression settings to use for the squashfs nix store. diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index cdf4faf3ffc7..7a56d7c0e5c8 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -12,7 +12,7 @@ libffi ? null , useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPowerPC + || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc) , # LLVM is conceptually a run-time-only depedendency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index af01582b1081..907d995a250a 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -11,7 +11,7 @@ libffi ? null , useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPowerPC + || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc) , # LLVM is conceptually a run-time-only depedendency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index a4cefe7294d8..6de0f201599f 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -14,7 +14,7 @@ libffi ? null , useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPowerPC + || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc) , # LLVM is conceptually a run-time-only depedendency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a diff --git a/pkgs/development/compilers/ghc/9.2.2.nix b/pkgs/development/compilers/ghc/9.2.2.nix index 0a572bff7ef2..880db4337893 100644 --- a/pkgs/development/compilers/ghc/9.2.2.nix +++ b/pkgs/development/compilers/ghc/9.2.2.nix @@ -13,7 +13,7 @@ libffi ? null , useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPowerPC + || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)) , # LLVM is conceptually a run-time-only depedendency, but for diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index a2afb7400c20..4f52ba0a6182 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -19,7 +19,7 @@ , elfutils # for DWARF support , useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPowerPC + || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)) , # LLVM is conceptually a run-time-only depedendency, but for diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix index 0c1514d01c25..aa9f4e3763b8 100644 --- a/pkgs/os-specific/linux/kernel-headers/default.nix +++ b/pkgs/os-specific/linux/kernel-headers/default.nix @@ -24,7 +24,7 @@ let flex bison python rsync ]; - extraIncludeDirs = lib.optional stdenvNoCC.hostPlatform.isPowerPC ["ppc"]; + extraIncludeDirs = lib.optional (with stdenvNoCC.hostPlatform; isPower && is32bit && isBigEndian) ["ppc"]; inherit patches; diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index d25e20bac8b2..4b6cceba238e 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -29,7 +29,7 @@ let mkIf (stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64 || - (stdenv.hostPlatform.isPowerPC && stdenv.hostPlatform.is64bit) || + (stdenv.hostPlatform.isPower && stdenv.hostPlatform.is64bit) || (stdenv.hostPlatform.isMips && stdenv.hostPlatform.is64bit)); options = {