From 9bcd91ba09dbe6d7cb93b2774a77596d914563ca Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 6 Apr 2024 15:11:48 -0500 Subject: [PATCH] build-fhsenv-bubblewrap: reference 32-bit binaries only if multiArch Fixes issues using bubblewrap'd fhsenvs in scenarios where i686 is not supported (such as Rosetta 2 emulation in a Linux VM on Apple Silicon). --- .../build-fhsenv-bubblewrap/buildFHSEnv.nix | 13 ++++++------- .../build-fhsenv-bubblewrap/default.nix | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix index 81813473a8db..2ab7847926e2 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix @@ -40,12 +40,11 @@ let isMultiBuild = multiArch && stdenv.system == "x86_64-linux"; isTargetBuild = !isMultiBuild; - # list of packages (usually programs) which are only be installed for the - # host's architecture + # list of packages (usually programs) which match the host's architecture + # (which includes stuff from multiPkgs) targetPaths = targetPkgs pkgs ++ (if multiPkgs == null then [] else multiPkgs pkgs); - # list of packages which are installed for both x86 and x86_64 on x86_64 - # systems + # list of packages which are for x86 (only multiPkgs, only for x86_64 hosts) multiPaths = multiPkgs pkgsi686Linux; # base packages of the chroot @@ -76,8 +75,8 @@ let ]; ldconfig = writeShellScriptBin "ldconfig" '' - # due to a glibc bug, 64-bit ldconfig complains about patchelf'd 32-bit libraries, so we're using 32-bit ldconfig - exec ${if stdenv.system == "x86_64-linux" then pkgsi686Linux.glibc.bin else pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@" + # due to a glibc bug, 64-bit ldconfig complains about patchelf'd 32-bit libraries, so we use 32-bit ldconfig when we have them + exec ${if isMultiBuild then pkgsi686Linux.glibc.bin else pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@" ''; etcProfile = writeText "profile" '' @@ -251,7 +250,7 @@ let in runCommandLocal "${name}-fhs" { passthru = { - inherit args baseTargetPaths targetPaths baseMultiPaths ldconfig; + inherit args baseTargetPaths targetPaths baseMultiPaths ldconfig isMultiBuild; }; } '' mkdir -p $out diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix index e06fb51dd4b6..c30a4dfb7ea3 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix @@ -252,7 +252,7 @@ let --symlink /etc/ld.so.cache ${glibc}/etc/ld.so.cache \ --ro-bind ${glibc}/etc/rpc ${glibc}/etc/rpc \ --remount-ro ${glibc}/etc \ - '' + optionalString (stdenv.isx86_64 && stdenv.isLinux) (indentLines '' + '' + optionalString fhsenv.isMultiBuild (indentLines '' --tmpfs ${pkgsi686Linux.glibc}/etc \ --symlink /etc/ld.so.conf ${pkgsi686Linux.glibc}/etc/ld.so.conf \ --symlink /etc/ld.so.cache ${pkgsi686Linux.glibc}/etc/ld.so.cache \