diff options
author | Robert Schütz <dev@schuetz-co.de> | 2021-02-26 10:56:17 +0100 |
---|---|---|
committer | Robert Schütz <dev@schuetz-co.de> | 2021-02-26 10:56:17 +0100 |
commit | 54757b35c11c58bbccbc7ec41fc286ef6cef9884 (patch) | |
tree | e61944e62365517622198dfd6fcf2e10687e26d1 /pkgs/build-support | |
parent | 109cbc400f4dd472d91f1f7768f42d7faac0cddb (diff) | |
parent | c456a2512f7a7558cbe25328a423762033822cc0 (diff) |
Merge branch 'staging-next' into staging
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix | 58 | ||||
-rw-r--r-- | pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix | 23 | ||||
-rw-r--r-- | pkgs/build-support/emacs/wrapper.nix | 8 | ||||
-rw-r--r-- | pkgs/build-support/rust/default.nix | 6 |
4 files changed, 83 insertions, 12 deletions
diff --git a/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix b/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix index 6592621570ce..3985eca42433 100644 --- a/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix +++ b/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix @@ -1,4 +1,6 @@ -{ lib, callPackage, runCommandLocal, writeShellScriptBin, coreutils, bubblewrap }: +{ lib, callPackage, runCommandLocal, writeShellScriptBin, glibc, pkgsi686Linux, coreutils, bubblewrap }: + +let buildFHSEnv = callPackage ./env.nix { }; in args @ { name @@ -60,29 +62,53 @@ let in concatStringsSep "\n " (map (file: "--ro-bind-try /etc/${file} /etc/${file}") files); + # Create this on the fly instead of linking from /nix + # The container might have to modify it and re-run ldconfig if there are + # issues running some binary with LD_LIBRARY_PATH + createLdConfCache = '' + cat > /etc/ld.so.conf <<EOF + /lib + /lib/x86_64-linux-gnu + /lib64 + /usr/lib + /usr/lib/x86_64-linux-gnu + /usr/lib64 + /lib/i386-linux-gnu + /lib32 + /usr/lib/i386-linux-gnu + /usr/lib32 + EOF + ldconfig &> /dev/null + ''; init = run: writeShellScriptBin "${name}-init" '' source /etc/profile + ${createLdConfCache} exec ${run} "$@" ''; bwrapCmd = { initArgs ? "" }: '' blacklist=(/nix /dev /proc /etc) ro_mounts=() + symlinks=() for i in ${env}/*; do path="/''${i##*/}" if [[ $path == '/etc' ]]; then - continue + : + elif [[ -L $i ]]; then + symlinks+=(--symlink "$(readlink "$i")" "$path") + blacklist+=("$path") + else + ro_mounts+=(--ro-bind "$i" "$path") + blacklist+=("$path") fi - ro_mounts+=(--ro-bind "$i" "$path") - blacklist+=("$path") done if [[ -d ${env}/etc ]]; then for i in ${env}/etc/*; do path="/''${i##*/}" - # NOTE: we're binding /etc/fonts from the host so we don't want to - # override it with a path from the FHS environment. - if [[ $path == '/fonts' ]]; then + # NOTE: we're binding /etc/fonts and /etc/ssl/certs from the host so we + # don't want to override it with a path from the FHS environment. + if [[ $path == '/fonts' || $path == '/ssl' ]]; then continue fi ro_mounts+=(--ro-bind "$i" "/etc$path") @@ -112,8 +138,26 @@ let ${lib.optionalString unshareCgroup "--unshare-cgroup"} --die-with-parent --ro-bind /nix /nix + # Our glibc will look for the cache in its own path in `/nix/store`. + # As such, we need a cache to exist there, because pressure-vessel + # depends on the existence of an ld cache. However, adding one + # globally proved to be a bad idea (see #100655), the solution we + # settled on being mounting one via bwrap. + # Also, the cache needs to go to both 32 and 64 bit glibcs, for games + # of both architectures to work. + --tmpfs ${glibc}/etc \ + --symlink /etc/ld.so.conf ${glibc}/etc/ld.so.conf \ + --symlink /etc/ld.so.cache ${glibc}/etc/ld.so.cache \ + --ro-bind ${glibc}/etc/rpc ${glibc}/etc/rpc \ + --remount-ro ${glibc}/etc \ + --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 \ ${etcBindFlags} "''${ro_mounts[@]}" + "''${symlinks[@]}" "''${auto_mounts[@]}" ${init runScript}/bin/${name}-init ${initArgs} ) diff --git a/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix b/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix index 8b2d46c4ae98..b9c719a4c78b 100644 --- a/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix +++ b/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix @@ -1,4 +1,4 @@ -{ stdenv, buildEnv, writeText, pkgs, pkgsi686Linux }: +{ stdenv, lib, buildEnv, writeText, writeShellScriptBin, pkgs, pkgsi686Linux }: { name, profile ? "" , targetPkgs ? pkgs: [], multiPkgs ? pkgs: [] @@ -49,6 +49,9 @@ let [ (toString gcc.cc.lib) ]; + ldconfig = writeShellScriptBin "ldconfig" '' + exec ${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' @@ -86,7 +89,8 @@ let # Composes a /usr-like directory structure staticUsrProfileTarget = buildEnv { name = "${name}-usr-target"; - paths = [ etcPkg ] ++ basePkgs ++ targetPaths; + # ldconfig wrapper must come first so it overrides the original ldconfig + paths = [ etcPkg ldconfig ] ++ basePkgs ++ targetPaths; extraOutputsToInstall = [ "out" "lib" "bin" ] ++ extraOutputsToInstall; ignoreCollisions = true; }; @@ -132,7 +136,20 @@ let mkdir -m0755 usr cd usr ${setupLibDirs} - for i in bin sbin share include; do + ${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 + cp -rLTf ${staticUsrProfileTarget}/share share + else + cp -rLf ${staticUsrProfileTarget}/share share + fi + fi + for i in bin sbin include; do if [ -d "${staticUsrProfileTarget}/$i" ]; then cp -rsHf "${staticUsrProfileTarget}/$i" "$i" fi diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix index f34835eaf096..fcbf5bcabe6d 100644 --- a/pkgs/build-support/emacs/wrapper.nix +++ b/pkgs/build-support/emacs/wrapper.nix @@ -147,9 +147,15 @@ runCommand # Begin the new site-start.el by loading the original, which sets some # NixOS-specific paths. Paths are searched in the reverse of the order # they are specified in, so user and system profile paths are searched last. + # + # NOTE: Avoid displaying messages early at startup by binding + # inhibit-message to t. This would prevent the Emacs GUI from showing up + # prematurely. The messages would still be logged to the *Messages* + # buffer. rm -f $siteStart $siteStartByteCompiled $subdirs $subdirsByteCompiled cat >"$siteStart" <<EOF - (load-file "$emacs/share/emacs/site-lisp/site-start.el") + (let ((inhibit-message t)) + (load-file "$emacs/share/emacs/site-lisp/site-start.el")) (add-to-list 'load-path "$out/share/emacs/site-lisp") (add-to-list 'exec-path "$out/bin") ${optionalString nativeComp '' diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index a7bd296d6738..bfa6c0d17cd6 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -25,6 +25,9 @@ # Legacy hash , cargoSha256 ? "" + # Name for the vendored dependencies tarball +, cargoDepsName ? name + , src ? null , srcs ? null , unpackPhase ? null @@ -59,7 +62,8 @@ let cargoDeps = if cargoVendorDir == null then fetchCargoTarball ({ - inherit name src srcs sourceRoot unpackPhase cargoUpdateHook; + inherit src srcs sourceRoot unpackPhase cargoUpdateHook; + name = cargoDepsName; hash = cargoHash; patches = cargoPatches; sha256 = cargoSha256; |