overlay: handle cross-only overrides consistently

This commit is contained in:
Daniel Barlow 2024-08-06 18:42:58 +01:00
parent 528afae8b1
commit 985df8792d
1 changed files with 71 additions and 63 deletions

View File

@ -1,5 +1,7 @@
final: prev: final: prev:
let let
isCross = final.stdenv.buildPlatform != final.stdenv.hostPlatform;
crossOnly = pkg : amendFn : if isCross then (amendFn pkg) else pkg;
extraPkgs = import ./pkgs/default.nix { extraPkgs = import ./pkgs/default.nix {
inherit (final) lib callPackage; inherit (final) lib callPackage;
}; };
@ -52,10 +54,12 @@ extraPkgs // {
# keep these alphabetical # keep these alphabetical
btrfs-progs = prev.btrfs-progs.override { btrfs-progs = crossOnly prev.btrfs-progs (
d: d.override {
udevSupport = false; udevSupport = false;
udev = null; udev = null;
}; }
);
chrony = chrony =
let chrony' = prev.chrony.overrideAttrs(o: { let chrony' = prev.chrony.overrideAttrs(o: {
@ -82,17 +86,13 @@ extraPkgs // {
# but https://github.com/NixOS/nixpkgs/issues/284734 # but https://github.com/NixOS/nixpkgs/issues/284734
# so we do surgery on the cmake derivation until that's fixed # so we do surgery on the cmake derivation until that's fixed
cmake = prev.cmake.overrideAttrs(o: cmake = crossOnly prev.cmake
# don't override the build cmake or we'll have to rebuild (d: d.overrideAttrs(o: {
# half the known universe to no useful benefit
if final.stdenv.buildPlatform != final.stdenv.hostPlatform
then {
preConfigure = preConfigure =
builtins.replaceStrings builtins.replaceStrings
["$configureFlags"] ["$configureFlags $cmakeFlags"] o.preConfigure; ["$configureFlags"] ["$configureFlags $cmakeFlags"] o.preConfigure;
} }
else {} ));
);
dnsmasq = dnsmasq =
let d = prev.dnsmasq.overrideAttrs(o: { let d = prev.dnsmasq.overrideAttrs(o: {
@ -114,20 +114,15 @@ extraPkgs // {
''; '';
}); });
elfutils = elfutils = crossOnly prev.elfutils
let native = (with final.stdenv; (buildPlatform == hostPlatform)); (d: let e = d.overrideAttrs(o: {
in if native
then prev.elfutils
else
let
e = prev.elfutils.overrideAttrs(o: {
configureFlags = o.configureFlags ++[ configureFlags = o.configureFlags ++[
"ac_cv_has_stdatomic=no" "ac_cv_has_stdatomic=no"
]; ];
}); });
in e.override { in e.override {
enableDebuginfod = false; enableDebuginfod = false;
}; });
hostapd = hostapd =
let let
@ -159,7 +154,7 @@ extraPkgs // {
# berlekey db needs libatomic which we haven't figured out yet. # berlekey db needs libatomic which we haven't figured out yet.
# disabling it means we don't have arpd # disabling it means we don't have arpd
iproute2 = prev.iproute2.override { db = null; }; iproute2 = crossOnly prev.iproute2 (d: d.override { db = null; });
kexec-tools-static = prev.kexec-tools.overrideAttrs(o: { kexec-tools-static = prev.kexec-tools.overrideAttrs(o: {
# For kexecboot we copy kexec into a ramdisk on the system being # For kexecboot we copy kexec into a ramdisk on the system being
@ -197,11 +192,9 @@ extraPkgs // {
]; ];
}); });
openssl = prev.openssl.overrideAttrs (o: openssl = crossOnly prev.openssl
with final; (d: d.overrideAttrs (o:
let cross = stdenv.buildPlatform != stdenv.hostPlatform; with final; {
in
{
# we want to apply # we want to apply
# https://patch-diff.githubusercontent.com/raw/openssl/openssl/pull/20273.patch"; # https://patch-diff.githubusercontent.com/raw/openssl/openssl/pull/20273.patch";
# which disables overriding the -march cflags to the wrong values, # which disables overriding the -march cflags to the wrong values,
@ -209,29 +202,44 @@ extraPkgs // {
# done. Do it the ugly way.. # done. Do it the ugly way..
postPatch = postPatch =
o.postPatch o.postPatch
+ ( + ''
lib.optionalString cross ''
sed -i.bak 's/linux.*-mips/linux-mops/' Configure sed -i.bak 's/linux.*-mips/linux-mops/' Configure
'' '';
);
# openssl with threads requires stdatomic which drags in libgcc # openssl with threads requires stdatomic which drags in libgcc
# as a dependency # as a dependency
configureFlags = [] configureFlags = ["no-threads"] ++ o.configureFlags;
++ (lib.optional cross "no-threads")
++ o.configureFlags;
# don't need or want this bash script # don't need or want this bash script
postInstall = o.postInstall + postInstall = o.postInstall + "rm $bin/bin/c_rehash\n";
(lib.optionalString cross "rm $bin/bin/c_rehash\n"); }
}); ));
pppBuild = prev.ppp; pppBuild = prev.ppp;
qemuLim = let q = prev.qemu.overrideAttrs (o: { qemuLim = let q = prev.qemu.overrideAttrs (o: {
patches = o.patches ++ [ patches = o.patches ++ [
./pkgs/qemu/arm-image-friendly-load-addr.patch ./pkgs/qemu/arm-image-friendly-load-addr.patch
(final.fetchpatch {
url = "https://lore.kernel.org/qemu-devel/20220322154658.1687620-1-raj.khem@gmail.com/raw";
hash = "sha256-jOsGka7xLkJznb9M90v5TsJraXXTAj84lcphcSxjYLU=";
})
]; ];
}); in q.override { nixosTestRunner = true; sdlSupport = false; }; }); in q.override {
nixosTestRunner = true;
hostCpuTargets = map (f: "${f}-softmmu") [
"arm" "aarch64" "mips" "mipsel"
];
sdlSupport = false;
numaSupport = false;
seccompSupport = false;
usbredirSupport = false;
libiscsiSupport = false;
tpmSupport = false;
uringSupport = false;
capstoneSupport = false;
texinfo = null;
};
rsyncSmall = rsyncSmall =
let let
@ -304,16 +312,16 @@ extraPkgs // {
''; '';
}; };
libusb1 = libusb1 = crossOnly prev.libusb1 (
let u = prev.libusb1.overrideAttrs(o: { d: let u = d.overrideAttrs(o: {
# don't use gcc libatomic because it vastly increases the # don't use gcc libatomic because it vastly increases the
# closure size # closure size
preConfigure = "sed -i.bak /__atomic_fetch_add_4/c\: configure.ac"; preConfigure = "sed -i.bak /__atomic_fetch_add_4/c\: configure.ac";
}); });
in u.override { in u.override {
enableUdev = final.stdenv.buildPlatform == final.stdenv.hostPlatform; enableUdev = false;
withDocs = false; withDocs = false;
}; });
util-linux-small = prev.util-linux.override { util-linux-small = prev.util-linux.override {
ncursesSupport = false; ncursesSupport = false;