From 167264179b81749dc5550bd29c7efa4e3e7b782e Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 06:23:45 +0200 Subject: [PATCH 1/8] buildFHSEnv: cleanup --- .../build-fhsenv-bubblewrap/buildFHSEnv.nix | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix index 2d927c7df731..f4fcc79b3936 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix @@ -36,7 +36,7 @@ let inherit (stdenv) is64bit; # use of glibc_multi is only supported on x86_64-linux - isMultiBuild = multiPkgs != null && stdenv.isx86_64 && stdenv.isLinux; + isMultiBuild = stdenv.system == "x86_64-linux"; isTargetBuild = !isMultiBuild; # list of packages (usually programs) which are only be installed for the @@ -51,21 +51,34 @@ let # these match the host's architecture, glibc_multi is used for multilib # builds. glibcLocales must be before glibc or glibc_multi as otherwiese # the wrong LOCALE_ARCHIVE will be used where only C.UTF-8 is available. - basePkgs = with pkgs; - [ glibcLocales - (if isMultiBuild then glibc_multi else glibc) - (toString gcc.cc.lib) bashInteractiveFHS coreutils less shadow su - gawk diffutils findutils gnused gnugrep - gnutar gzip bzip2 xz - ]; - baseMultiPkgs = with pkgsi686Linux; - [ (toString gcc.cc.lib) - ]; + basePkgs = with pkgs; [ + glibcLocales + (if isMultiBuild then glibc_multi else glibc) + (toString gcc.cc.lib) + bashInteractiveFHS + coreutils + less + shadow + su + gawk + diffutils + findutils + gnused + gnugrep + gnutar + gzip + bzip2 + xz + ]; + baseMultiPkgs = with pkgsi686Linux; [ + (toString gcc.cc.lib) + ]; 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.isx86_64 && stdenv.isLinux then pkgsi686Linux.glibc.bin else pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@" + 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 "$@" ''; + etcProfile = writeText "profile" '' export PS1='${name}-chrootenv:\u@\h:\w\$ ' export LOCALE_ARCHIVE='/usr/lib/locale/locale-archive' @@ -104,7 +117,7 @@ let # Compose /etc for the chroot environment etcPkg = runCommandLocal "${name}-chrootenv-etc" { } '' mkdir -p $out/etc - cd $out/etc + pushd $out/etc # environment variables ln -s ${etcProfile} profile @@ -172,13 +185,18 @@ let ln -s lib64 lib # copy glibc stuff - cp -rsHf ${staticUsrProfileTarget}/lib/32/* lib32/ && chmod u+w -R lib32/ + cp -rsHf ${staticUsrProfileTarget}/lib/32/* lib32/ + chmod u+w -R lib32/ # copy content of multiPaths (32bit libs) - [ -d ${staticUsrProfileMulti}/lib ] && cp -rsHf ${staticUsrProfileMulti}/lib/* lib32/ && chmod u+w -R lib32/ + if [ -d ${staticUsrProfileMulti}/lib ]; then + cp -rsHf ${staticUsrProfileMulti}/lib/* lib32/ + chmod u+w -R lib32/ + fi # copy content of targetPaths (64bit libs) - cp -rsHf ${staticUsrProfileTarget}/lib/* lib64/ && chmod u+w -R lib64/ + cp -rsHf ${staticUsrProfileTarget}/lib/* lib64/ + chmod u+w -R lib64/ # symlink 32-bit ld-linux.so ln -Ls ${staticUsrProfileTarget}/lib/32/ld-linux.so.2 lib/ @@ -191,13 +209,15 @@ let # the target profile is the actual profile that will be used for the chroot setupTargetProfile = '' mkdir -m0755 usr - cd usr + pushd usr + ${setupLibDirs} - ${lib.optionalString isMultiBuild '' + + '' + lib.optionalString isMultiBuild '' if [ -d "${staticUsrProfileMulti}/share" ]; then cp -rLf ${staticUsrProfileMulti}/share share fi - ''} + '' + '' if [ -d "${staticUsrProfileTarget}/share" ]; then if [ -d share ]; then chmod -R 755 share @@ -223,18 +243,19 @@ let ln -s "$i" fi done + + popd ''; in runCommandLocal "${name}-fhs" { passthru = { - inherit args multiPaths targetPaths; + inherit args multiPaths targetPaths ldconfig; }; } '' mkdir -p $out - cd $out + pushd $out + ${setupTargetProfile} - cd $out ${extraBuildCommands} - cd $out ${lib.optionalString isMultiBuild extraBuildCommandsMulti} '' From 62b2adc753eaec8c3b3b10593055e96450c82b36 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 06:36:05 +0200 Subject: [PATCH 2/8] buildFHSEnv: add multiArch flag The intention is to allow the user control over whether 32bit deps are supposed to be included in the fhsenv --- doc/builders/special/fhs-environments.section.md | 2 ++ pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/builders/special/fhs-environments.section.md b/doc/builders/special/fhs-environments.section.md index 5a248e4ead92..8145fbd730f7 100644 --- a/doc/builders/special/fhs-environments.section.md +++ b/doc/builders/special/fhs-environments.section.md @@ -11,6 +11,8 @@ Accepted arguments are: Packages to be installed for the main host's architecture (i.e. x86_64 on x86_64 installations). Along with libraries binaries are also installed. - `multiPkgs` Packages to be installed for all architectures supported by a host (i.e. i686 and x86_64 on x86_64 installations). Only libraries are installed by default. +- `multiArch` + Whether to install 32bit multiPkgs into the FHSEnv in 64bit environments - `extraBuildCommands` Additional commands to be executed for finalizing the directory structure. - `extraBuildCommandsMulti` diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix index f4fcc79b3936..15504916af63 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix @@ -12,6 +12,7 @@ , profile ? "" , targetPkgs ? pkgs: [] , multiPkgs ? pkgs: [] +, multiArch ? true # Whether to include 32bit packages , extraBuildCommands ? "" , extraBuildCommandsMulti ? "" , extraOutputsToInstall ? [] @@ -35,8 +36,8 @@ let inherit (stdenv) is64bit; - # use of glibc_multi is only supported on x86_64-linux - isMultiBuild = stdenv.system == "x86_64-linux"; + # "use of glibc_multi is only supported on x86_64-linux" + isMultiBuild = multiArch && stdenv.system == "x86_64-linux"; isTargetBuild = !isMultiBuild; # list of packages (usually programs) which are only be installed for the From f0c58f6e96d821fcb32b507cb453df4fef8f59cc Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 13:35:55 +0200 Subject: [PATCH 3/8] tree-wide: use new multiArch buildFHSEnv argument This is much more direct and sensible than setting a function null --- pkgs/applications/audio/plexamp/default.nix | 2 +- pkgs/applications/blockchains/mycrypto/default.nix | 2 +- pkgs/applications/misc/chrysalis/default.nix | 2 +- pkgs/applications/misc/joplin-desktop/default.nix | 2 +- pkgs/applications/misc/marktext/default.nix | 2 +- pkgs/applications/misc/notable/default.nix | 2 +- pkgs/applications/misc/zettlr/default.nix | 2 +- pkgs/applications/networking/Sylk/default.nix | 2 +- pkgs/applications/networking/browsers/polypane/default.nix | 2 +- pkgs/applications/networking/cluster/octant/desktop.nix | 2 +- pkgs/applications/networking/station/default.nix | 2 +- pkgs/applications/office/tusk/default.nix | 2 +- pkgs/development/embedded/arduino/arduino-core/chrootenv.nix | 2 +- pkgs/development/tools/database/beekeeper-studio/default.nix | 2 +- pkgs/development/web/bloomrpc/default.nix | 2 +- pkgs/tools/misc/flexoptix-app/default.nix | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkgs/applications/audio/plexamp/default.nix b/pkgs/applications/audio/plexamp/default.nix index 5c1325819730..111f97969e9f 100644 --- a/pkgs/applications/audio/plexamp/default.nix +++ b/pkgs/applications/audio/plexamp/default.nix @@ -16,7 +16,7 @@ let in appimageTools.wrapType2 { inherit pname version src; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = pkgs: appimageTools.defaultFhsEnvArgs.multiPkgs pkgs ++ [ pkgs.bash ]; extraInstallCommands = '' diff --git a/pkgs/applications/blockchains/mycrypto/default.nix b/pkgs/applications/blockchains/mycrypto/default.nix index fd2b3347afd0..514e2e198e7a 100644 --- a/pkgs/applications/blockchains/mycrypto/default.nix +++ b/pkgs/applications/blockchains/mycrypto/default.nix @@ -28,7 +28,7 @@ let in appimageTools.wrapType2 rec { inherit name src; - multiPkgs = null; # no p32bit needed + multiArch = false; # no p32bit needed extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; extraInstallCommands = '' diff --git a/pkgs/applications/misc/chrysalis/default.nix b/pkgs/applications/misc/chrysalis/default.nix index ddf54d64dbe3..d5b35fc04ce4 100644 --- a/pkgs/applications/misc/chrysalis/default.nix +++ b/pkgs/applications/misc/chrysalis/default.nix @@ -14,7 +14,7 @@ in appimageTools.wrapAppImage rec { }; }; - multiPkgs = null; + multiArch = false; extraPkgs = p: (appimageTools.defaultFhsEnvArgs.multiPkgs p) ++ [ p.glib ]; diff --git a/pkgs/applications/misc/joplin-desktop/default.nix b/pkgs/applications/misc/joplin-desktop/default.nix index 785022bd236a..2a5dd7463d4d 100644 --- a/pkgs/applications/misc/joplin-desktop/default.nix +++ b/pkgs/applications/misc/joplin-desktop/default.nix @@ -47,7 +47,7 @@ let export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; extraInstallCommands = '' mv $out/bin/{${name},${pname}} diff --git a/pkgs/applications/misc/marktext/default.nix b/pkgs/applications/misc/marktext/default.nix index a99332ae82fd..bc9418d57838 100644 --- a/pkgs/applications/misc/marktext/default.nix +++ b/pkgs/applications/misc/marktext/default.nix @@ -20,7 +20,7 @@ appimageTools.wrapType2 rec { export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = p: (appimageTools.defaultFhsEnvArgs.multiPkgs p) ++ [ p.libsecret p.xorg.libxkbfile diff --git a/pkgs/applications/misc/notable/default.nix b/pkgs/applications/misc/notable/default.nix index e51e49fd8931..4606ee943278 100644 --- a/pkgs/applications/misc/notable/default.nix +++ b/pkgs/applications/misc/notable/default.nix @@ -26,7 +26,7 @@ appimageTools.wrapType2 rec { export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = p: (appimageTools.defaultFhsEnvArgs.multiPkgs p) ++ [ p.at-spi2-atk p.at-spi2-core ]; extraInstallCommands = '' mv $out/bin/{${name},${pname}} diff --git a/pkgs/applications/misc/zettlr/default.nix b/pkgs/applications/misc/zettlr/default.nix index cfee5cb43e3f..586d9f95f1f7 100644 --- a/pkgs/applications/misc/zettlr/default.nix +++ b/pkgs/applications/misc/zettlr/default.nix @@ -21,7 +21,7 @@ in appimageTools.wrapType2 rec { inherit name src; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = pkgs: (appimageTools.defaultFhsEnvArgs.multiPkgs pkgs) ++ [ texlive pandoc ]; extraInstallCommands = '' mv $out/bin/{${name},${pname}} diff --git a/pkgs/applications/networking/Sylk/default.nix b/pkgs/applications/networking/Sylk/default.nix index 18e36cb70280..cc9e218bad35 100644 --- a/pkgs/applications/networking/Sylk/default.nix +++ b/pkgs/applications/networking/Sylk/default.nix @@ -17,7 +17,7 @@ appimageTools.wrapType2 rec { export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; extraInstallCommands = "mv $out/bin/{${name},${pname}}"; diff --git a/pkgs/applications/networking/browsers/polypane/default.nix b/pkgs/applications/networking/browsers/polypane/default.nix index 9e9e1ea49596..617d52788d73 100644 --- a/pkgs/applications/networking/browsers/polypane/default.nix +++ b/pkgs/applications/networking/browsers/polypane/default.nix @@ -16,7 +16,7 @@ let in appimageTools.wrapType2 { inherit pname src version; - multiPkgs = null; + multiArch = false; extraPkgs = pkgs: appimageTools.defaultFhsEnvArgs.multiPkgs pkgs ++ [ pkgs.bash ]; extraInstallCommands = '' diff --git a/pkgs/applications/networking/cluster/octant/desktop.nix b/pkgs/applications/networking/cluster/octant/desktop.nix index b34e167e8c94..fc48ce1e9ef4 100644 --- a/pkgs/applications/networking/cluster/octant/desktop.nix +++ b/pkgs/applications/networking/cluster/octant/desktop.nix @@ -27,7 +27,7 @@ let export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; extraInstallCommands = let appimageContents = appimageTools.extractType2 { inherit name src; }; in diff --git a/pkgs/applications/networking/station/default.nix b/pkgs/applications/networking/station/default.nix index f60bcf8b7bef..9160568ee483 100644 --- a/pkgs/applications/networking/station/default.nix +++ b/pkgs/applications/networking/station/default.nix @@ -20,7 +20,7 @@ in appimageTools.wrapType2 rec { export LC_ALL=C.UTF-8 ''; - multiPkgs = null; + multiArch = false; extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; extraInstallCommands = '' mv $out/bin/{${name},${pname}} diff --git a/pkgs/applications/office/tusk/default.nix b/pkgs/applications/office/tusk/default.nix index d35720672846..52bb3eff49b7 100644 --- a/pkgs/applications/office/tusk/default.nix +++ b/pkgs/applications/office/tusk/default.nix @@ -31,7 +31,7 @@ in appimageTools.wrapType2 rec { export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs; extraInstallCommands = '' mv $out/bin/{${pname}-${version},${pname}} diff --git a/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix b/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix index 1313a9aeada3..a97fa50aebf2 100644 --- a/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix +++ b/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix @@ -14,7 +14,7 @@ buildFHSEnv { pyserial ])) ]); - multiPkgs = null; + multiArch = false; extraInstallCommands = '' ${lib.optionalString withGui '' diff --git a/pkgs/development/tools/database/beekeeper-studio/default.nix b/pkgs/development/tools/database/beekeeper-studio/default.nix index 12e5a656d1aa..be53f57cac61 100644 --- a/pkgs/development/tools/database/beekeeper-studio/default.nix +++ b/pkgs/development/tools/database/beekeeper-studio/default.nix @@ -18,7 +18,7 @@ in appimageTools.wrapType2 { inherit name src; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = pkgs: appimageTools.defaultFhsEnvArgs.multiPkgs pkgs ++ [ pkgs.bash ]; extraInstallCommands = '' diff --git a/pkgs/development/web/bloomrpc/default.nix b/pkgs/development/web/bloomrpc/default.nix index 59ab32131c2d..037e7f4931a1 100644 --- a/pkgs/development/web/bloomrpc/default.nix +++ b/pkgs/development/web/bloomrpc/default.nix @@ -21,7 +21,7 @@ appimageTools.wrapType2 { export LC_ALL=C.UTF-8 ''; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = pkgs: appimageTools.defaultFhsEnvArgs.multiPkgs pkgs ++ [ pkgs.bash ]; extraInstallCommands = '' diff --git a/pkgs/tools/misc/flexoptix-app/default.nix b/pkgs/tools/misc/flexoptix-app/default.nix index 4cd81c8c640f..45f28b8ee442 100644 --- a/pkgs/tools/misc/flexoptix-app/default.nix +++ b/pkgs/tools/misc/flexoptix-app/default.nix @@ -28,7 +28,7 @@ in appimageTools.wrapAppImage { inherit pname version; src = appimageContents; - multiPkgs = null; # no 32bit needed + multiArch = false; # no 32bit needed extraPkgs = { pkgs, ... }@args: [ pkgs.hidapi ] ++ appimageTools.defaultFhsEnvArgs.multiPkgs args; From 173962eef901c40356d14bfdfe223194427f32ea Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 06:41:07 +0200 Subject: [PATCH 4/8] steam: declare need for multiArch explicitly --- pkgs/games/steam/fhsenv.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/games/steam/fhsenv.nix b/pkgs/games/steam/fhsenv.nix index dee43cb4b2e0..af29cc02d4b7 100644 --- a/pkgs/games/steam/fhsenv.nix +++ b/pkgs/games/steam/fhsenv.nix @@ -61,6 +61,9 @@ let in buildFHSEnv rec { name = "steam"; + # Steam still needs 32bit and various native games do too + multiArch = true; + targetPkgs = pkgs: with pkgs; [ steam # License agreement From ff777e9f390f86e9ce6dd1d160a669c9b1b12d98 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 06:41:24 +0200 Subject: [PATCH 5/8] lutris: declare need for multiArch explicitly --- pkgs/applications/misc/lutris/fhsenv.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/applications/misc/lutris/fhsenv.nix b/pkgs/applications/misc/lutris/fhsenv.nix index 59c8be448d14..ca93cf7bf2f7 100644 --- a/pkgs/applications/misc/lutris/fhsenv.nix +++ b/pkgs/applications/misc/lutris/fhsenv.nix @@ -18,6 +18,9 @@ in buildFHSEnv { runScript = "lutris"; + # Many native and WINE games need 32bit + multiArch = true; + targetPkgs = pkgs: with pkgs; [ lutris-unwrapped From c4025e244bce60abe70ecf0f9dd97423e884b10b Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 12:02:07 +0200 Subject: [PATCH 6/8] heroic: declare need for multiArch explicitly Co-authored-by: Aidan Gauland --- pkgs/games/heroic/fhsenv.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/games/heroic/fhsenv.nix b/pkgs/games/heroic/fhsenv.nix index d47a567999c2..40a8ea37efae 100644 --- a/pkgs/games/heroic/fhsenv.nix +++ b/pkgs/games/heroic/fhsenv.nix @@ -9,6 +9,9 @@ buildFHSEnv { runScript = "heroic"; + # Many Wine and native games need 32-bit libraries. + multiArch = true; + targetPkgs = pkgs: with pkgs; [ heroic-unwrapped gamemode From 4194dc3819ac26cdfe067806ea241ed5f958c574 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 12:02:15 +0200 Subject: [PATCH 7/8] bottles: declare need for multiArch explicitly --- pkgs/applications/misc/bottles/fhsenv.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/applications/misc/bottles/fhsenv.nix b/pkgs/applications/misc/bottles/fhsenv.nix index 3096eab69728..969a2d8178ef 100644 --- a/pkgs/applications/misc/bottles/fhsenv.nix +++ b/pkgs/applications/misc/bottles/fhsenv.nix @@ -7,6 +7,9 @@ }: let fhsEnv = { + # Many WINE games need 32bit + multiArch = true; + targetPkgs = pkgs: with pkgs; [ bottles-unwrapped # This only allows to enable the toggle, vkBasalt won't work if not installed with environment.systemPackages (or nix-env) From 67ac4b83ec29bc943447e6377aa3472efa33e3be Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 1 Jul 2023 06:42:31 +0200 Subject: [PATCH 8/8] buildFHSEnv: disable multiArch by default Most FHSEnv-wrapped packages in Nixpkgs wrap a x86_64-linux binary; making multiArch unnecessary bloat closure size. Saves about 1G in anki-bin. This makes multiArch FHSEnvs the exception rather than the rule. --- pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix index 15504916af63..3e6fc922906f 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/buildFHSEnv.nix @@ -12,7 +12,7 @@ , profile ? "" , targetPkgs ? pkgs: [] , multiPkgs ? pkgs: [] -, multiArch ? true # Whether to include 32bit packages +, multiArch ? false # Whether to include 32bit packages , extraBuildCommands ? "" , extraBuildCommandsMulti ? "" , extraOutputsToInstall ? []