buildFHSEnv: restrict pkgsi686Linux to x86_64-linux

This commit is contained in:
Weijia Wang 2023-04-22 15:31:27 +03:00
parent 40e4b45adc
commit 3c6e26b2ee
2 changed files with 5 additions and 1 deletions

View file

@ -64,7 +64,7 @@ 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 ${pkgsi686Linux.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@"
exec ${if stdenv.isx86_64 && stdenv.isLinux then pkgsi686Linux.glibc.bin else pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@"
'';
etcProfile = writeText "profile" ''
export PS1='${name}-chrootenv:\u@\h:\w\$ '

View file

@ -1,4 +1,5 @@
{ lib
, stdenv
, callPackage
, runCommandLocal
, writeShellScript
@ -113,6 +114,7 @@ let
exec ${run} "$@"
'';
indentLines = str: lib.concatLines (map (s: " " + s) (filter (s: s != "") (lib.splitString "\n" str)));
bwrapCmd = { initArgs ? "" }: ''
ignored=(/nix /dev /proc /etc)
ro_mounts=()
@ -202,11 +204,13 @@ let
--symlink /etc/ld.so.cache ${glibc}/etc/ld.so.cache \
--ro-bind ${glibc}/etc/rpc ${glibc}/etc/rpc \
--remount-ro ${glibc}/etc \
'' + lib.optionalString (stdenv.isx86_64 && stdenv.isLinux) (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 \
--ro-bind ${pkgsi686Linux.glibc}/etc/rpc ${pkgsi686Linux.glibc}/etc/rpc \
--remount-ro ${pkgsi686Linux.glibc}/etc \
'') + ''
"''${ro_mounts[@]}"
"''${symlinks[@]}"
"''${auto_mounts[@]}"