Avoid top-level with ...; in pkgs/top-level/release-cross.nix

Also, `inherit (lib) ...;` and `inherit (builtins) ...;` to create
smaller expressions in this file.
This commit is contained in:
Philip Taron 2024-03-06 11:20:29 -08:00
parent 210c9eda8a
commit 30ad443519
No known key found for this signature in database

View file

@ -20,9 +20,40 @@
nixpkgsArgs ? { config = { allowUnfree = false; inHydra = true; }; }
}:
with import ./release-lib.nix { inherit supportedSystems scrubJobs nixpkgsArgs; };
let
release-lib = import ./release-lib.nix {
inherit supportedSystems scrubJobs nixpkgsArgs;
};
inherit (release-lib)
all
assertTrue
darwin
forMatchingSystems
hydraJob'
linux
mapTestOnCross
pkgsForCross
unix
;
inherit (release-lib.lib)
mapAttrs
addMetaAttrs
elem
getAttrFromPath
isDerivation
maintainers
mapAttrsRecursive
mapAttrsRecursiveCond
recursiveUpdate
systems
;
inherit (release-lib.lib.attrsets)
removeAttrs
;
nativePlatforms = all;
embedded = {
@ -42,14 +73,14 @@ let
cargo = nativePlatforms;
};
gnuCommon = lib.recursiveUpdate common {
gnuCommon = recursiveUpdate common {
buildPackages.gcc = nativePlatforms;
coreutils = nativePlatforms;
haskell.packages.ghcHEAD.hello = nativePlatforms;
haskellPackages.hello = nativePlatforms;
};
linuxCommon = lib.recursiveUpdate gnuCommon {
linuxCommon = recursiveUpdate gnuCommon {
buildPackages.gdb = nativePlatforms;
bison = nativePlatforms;
@ -60,7 +91,7 @@ let
patch = nativePlatforms;
};
windowsCommon = lib.recursiveUpdate gnuCommon {
windowsCommon = recursiveUpdate gnuCommon {
boehmgc = nativePlatforms;
guile_1_8 = nativePlatforms;
libffi = nativePlatforms;
@ -120,7 +151,7 @@ in
# good idea lest there be some irrelevant pass-through debug attrs that
# cause false negatives.
testEqualOne = path: system: let
f = path: crossSystem: system: builtins.toString (lib.getAttrFromPath path (pkgsForCross crossSystem system));
f = path: crossSystem: system: toString (getAttrFromPath path (pkgsForCross crossSystem system));
in assertTrue (
f path null system
==
@ -129,7 +160,7 @@ in
testEqual = path: systems: forMatchingSystems systems (testEqualOne path);
mapTestEqual = lib.mapAttrsRecursive testEqual;
mapTestEqual = mapAttrsRecursive testEqual;
in mapTestEqual {
boehmgc = nativePlatforms;
@ -142,105 +173,107 @@ in
guile = nativePlatforms;
};
crossIphone64 = mapTestOnCross lib.systems.examples.iphone64 darwinCommon;
crossIphone64 = mapTestOnCross systems.examples.iphone64 darwinCommon;
crossIphone32 = mapTestOnCross lib.systems.examples.iphone32 darwinCommon;
crossIphone32 = mapTestOnCross systems.examples.iphone32 darwinCommon;
/* Test some cross builds to the Sheevaplug */
crossSheevaplugLinux = mapTestOnCross lib.systems.examples.sheevaplug (linuxCommon // {
crossSheevaplugLinux = mapTestOnCross systems.examples.sheevaplug (linuxCommon // {
ubootSheevaplug = nativePlatforms;
});
/* Test some cross builds on 32 bit mingw-w64 */
crossMingw32 = mapTestOnCross lib.systems.examples.mingw32 windowsCommon;
crossMingw32 = mapTestOnCross systems.examples.mingw32 windowsCommon;
/* Test some cross builds on 64 bit mingw-w64 */
crossMingwW64 = mapTestOnCross lib.systems.examples.mingwW64 windowsCommon;
crossMingwW64 = mapTestOnCross systems.examples.mingwW64 windowsCommon;
/* Linux on mipsel */
fuloongminipc = mapTestOnCross lib.systems.examples.fuloongminipc linuxCommon;
ben-nanonote = mapTestOnCross lib.systems.examples.ben-nanonote linuxCommon;
fuloongminipc = mapTestOnCross systems.examples.fuloongminipc linuxCommon;
ben-nanonote = mapTestOnCross systems.examples.ben-nanonote linuxCommon;
/* Javacript */
ghcjs = mapTestOnCross lib.systems.examples.ghcjs {
ghcjs = mapTestOnCross systems.examples.ghcjs {
haskell.packages.ghcjs.hello = nativePlatforms;
haskell.packages.native-bignum.ghcHEAD.hello = nativePlatforms;
haskellPackages.hello = nativePlatforms;
};
/* Linux on Raspberrypi */
rpi = mapTestOnCross lib.systems.examples.raspberryPi rpiCommon;
rpi-musl = mapTestOnCross lib.systems.examples.muslpi rpiCommon;
rpi = mapTestOnCross systems.examples.raspberryPi rpiCommon;
rpi-musl = mapTestOnCross systems.examples.muslpi rpiCommon;
/* Linux on the Remarkable */
remarkable1 = mapTestOnCross lib.systems.examples.remarkable1 linuxCommon;
remarkable2 = mapTestOnCross lib.systems.examples.remarkable2 linuxCommon;
remarkable1 = mapTestOnCross systems.examples.remarkable1 linuxCommon;
remarkable2 = mapTestOnCross systems.examples.remarkable2 linuxCommon;
/* Linux on armv7l-hf */
armv7l-hf = mapTestOnCross lib.systems.examples.armv7l-hf-multiplatform linuxCommon;
armv7l-hf = mapTestOnCross systems.examples.armv7l-hf-multiplatform linuxCommon;
pogoplug4 = mapTestOnCross lib.systems.examples.pogoplug4 linuxCommon;
pogoplug4 = mapTestOnCross systems.examples.pogoplug4 linuxCommon;
/* Linux on aarch64 */
aarch64 = mapTestOnCross lib.systems.examples.aarch64-multiplatform linuxCommon;
aarch64-musl = mapTestOnCross lib.systems.examples.aarch64-multiplatform-musl linuxCommon;
aarch64 = mapTestOnCross systems.examples.aarch64-multiplatform linuxCommon;
aarch64-musl = mapTestOnCross systems.examples.aarch64-multiplatform-musl linuxCommon;
/* Linux on RISCV */
riscv64 = mapTestOnCross lib.systems.examples.riscv64 linuxCommon;
riscv32 = mapTestOnCross lib.systems.examples.riscv32 linuxCommon;
riscv64 = mapTestOnCross systems.examples.riscv64 linuxCommon;
riscv32 = mapTestOnCross systems.examples.riscv32 linuxCommon;
/* Linux on LoongArch */
loongarch64-linux = mapTestOnCross lib.systems.examples.loongarch64-linux linuxCommon;
loongarch64-linux = mapTestOnCross systems.examples.loongarch64-linux linuxCommon;
m68k = mapTestOnCross lib.systems.examples.m68k linuxCommon;
s390x = mapTestOnCross lib.systems.examples.s390x linuxCommon;
m68k = mapTestOnCross systems.examples.m68k linuxCommon;
s390x = mapTestOnCross systems.examples.s390x linuxCommon;
/* (Cross-compiled) Linux on x86 */
x86_64-musl = mapTestOnCross lib.systems.examples.musl64 linuxCommon;
x86_64-gnu = mapTestOnCross lib.systems.examples.gnu64 linuxCommon;
i686-musl = mapTestOnCross lib.systems.examples.musl32 linuxCommon;
i686-gnu = mapTestOnCross lib.systems.examples.gnu32 linuxCommon;
x86_64-musl = mapTestOnCross systems.examples.musl64 linuxCommon;
x86_64-gnu = mapTestOnCross systems.examples.gnu64 linuxCommon;
i686-musl = mapTestOnCross systems.examples.musl32 linuxCommon;
i686-gnu = mapTestOnCross systems.examples.gnu32 linuxCommon;
ppc64le = mapTestOnCross lib.systems.examples.powernv linuxCommon;
ppc64le-musl = mapTestOnCross lib.systems.examples.musl-power linuxCommon;
ppc64le = mapTestOnCross systems.examples.powernv linuxCommon;
ppc64le-musl = mapTestOnCross systems.examples.musl-power linuxCommon;
android64 = mapTestOnCross lib.systems.examples.aarch64-android-prebuilt linuxCommon;
android32 = mapTestOnCross lib.systems.examples.armv7a-android-prebuilt linuxCommon;
android64 = mapTestOnCross systems.examples.aarch64-android-prebuilt linuxCommon;
android32 = mapTestOnCross systems.examples.armv7a-android-prebuilt linuxCommon;
wasi32 = mapTestOnCross lib.systems.examples.wasi32 wasiCommon;
wasi32 = mapTestOnCross systems.examples.wasi32 wasiCommon;
msp430 = mapTestOnCross lib.systems.examples.msp430 embedded;
mmix = mapTestOnCross lib.systems.examples.mmix embedded;
vc4 = mapTestOnCross lib.systems.examples.vc4 embedded;
or1k = mapTestOnCross lib.systems.examples.or1k embedded;
avr = mapTestOnCross lib.systems.examples.avr embedded;
arm-embedded = mapTestOnCross lib.systems.examples.arm-embedded embedded;
armhf-embedded = mapTestOnCross lib.systems.examples.armhf-embedded embedded;
aarch64-embedded = mapTestOnCross lib.systems.examples.aarch64-embedded embedded;
aarch64be-embedded = mapTestOnCross lib.systems.examples.aarch64be-embedded embedded;
powerpc-embedded = mapTestOnCross lib.systems.examples.ppc-embedded embedded;
powerpcle-embedded = mapTestOnCross lib.systems.examples.ppcle-embedded embedded;
i686-embedded = mapTestOnCross lib.systems.examples.i686-embedded embedded;
x86_64-embedded = mapTestOnCross lib.systems.examples.x86_64-embedded embedded;
riscv64-embedded = mapTestOnCross lib.systems.examples.riscv64-embedded embedded;
riscv32-embedded = mapTestOnCross lib.systems.examples.riscv32-embedded embedded;
rx-embedded = mapTestOnCross lib.systems.examples.rx-embedded embedded;
msp430 = mapTestOnCross systems.examples.msp430 embedded;
mmix = mapTestOnCross systems.examples.mmix embedded;
vc4 = mapTestOnCross systems.examples.vc4 embedded;
or1k = mapTestOnCross systems.examples.or1k embedded;
avr = mapTestOnCross systems.examples.avr embedded;
arm-embedded = mapTestOnCross systems.examples.arm-embedded embedded;
armhf-embedded = mapTestOnCross systems.examples.armhf-embedded embedded;
aarch64-embedded = mapTestOnCross systems.examples.aarch64-embedded embedded;
aarch64be-embedded = mapTestOnCross systems.examples.aarch64be-embedded embedded;
powerpc-embedded = mapTestOnCross systems.examples.ppc-embedded embedded;
powerpcle-embedded = mapTestOnCross systems.examples.ppcle-embedded embedded;
i686-embedded = mapTestOnCross systems.examples.i686-embedded embedded;
x86_64-embedded = mapTestOnCross systems.examples.x86_64-embedded embedded;
riscv64-embedded = mapTestOnCross systems.examples.riscv64-embedded embedded;
riscv32-embedded = mapTestOnCross systems.examples.riscv32-embedded embedded;
rx-embedded = mapTestOnCross systems.examples.rx-embedded embedded;
x86_64-freebsd = mapTestOnCross lib.systems.examples.x86_64-freebsd common;
x86_64-netbsd = mapTestOnCross lib.systems.examples.x86_64-netbsd common;
x86_64-freebsd = mapTestOnCross systems.examples.x86_64-freebsd common;
x86_64-netbsd = mapTestOnCross systems.examples.x86_64-netbsd common;
# we test `embedded` instead of `linuxCommon` because very few packages
# successfully cross-compile to Redox so far
x86_64-redox = mapTestOnCross lib.systems.examples.x86_64-unknown-redox embedded;
x86_64-redox = mapTestOnCross systems.examples.x86_64-unknown-redox embedded;
/* Cross-built bootstrap tools for every supported platform */
bootstrapTools = let
tools = import ../stdenv/linux/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
maintainers = [ lib.maintainers.dezgeg ];
meta = {
maintainers = [ maintainers.dezgeg ];
};
mkBootstrapToolsJob = drv:
assert lib.elem drv.system supportedSystems;
hydraJob' (lib.addMetaAttrs { inherit maintainers; } drv);
in lib.mapAttrsRecursiveCond (as: !lib.isDerivation as) (name: mkBootstrapToolsJob)
assert elem drv.system supportedSystems;
hydraJob' (addMetaAttrs meta drv);
in mapAttrsRecursiveCond (as: !isDerivation as) (name: mkBootstrapToolsJob)
# The `bootstrapTools.${platform}.bootstrapTools` derivation
# *unpacks* the bootstrap-files using their own `busybox` binary,
# so it will fail unless buildPlatform.canExecute hostPlatform.
@ -248,9 +281,9 @@ in
# attribute, so there is no way to detect this -- we must add it
# as a special case. We filter the "test" attribute (only from
# *cross*-built bootstrapTools) for the same reason.
(builtins.mapAttrs (_: v: builtins.removeAttrs v ["bootstrapTools" "test"]) tools);
(mapAttrs (_: v: removeAttrs v ["bootstrapTools" "test"]) tools);
# Cross-built nixStatic for platforms for enabled-but-unsupported platforms
mips64el-nixCrossStatic = mapTestOnCross lib.systems.examples.mips64el-linux-gnuabi64 nixCrossStatic;
powerpc64le-nixCrossStatic = mapTestOnCross lib.systems.examples.powernv nixCrossStatic;
mips64el-nixCrossStatic = mapTestOnCross systems.examples.mips64el-linux-gnuabi64 nixCrossStatic;
powerpc64le-nixCrossStatic = mapTestOnCross systems.examples.powernv nixCrossStatic;
}