git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #114024 from LuigiPiucco/pressure-vessel

steam: fix proton versions with pressure-vessel

commitcdcaafc3fef5e448c847f68765c2160212fc9237 authorBernardo Meurer <bernardo@meurer.org> dateTue 23 Feb 2021, 19:20 (6 years ago) parentc01e05e548d50d
4 files changed+92−8
nixos/modules/programs/steam.nix+8−1 pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix+48−4 pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix+20−3 pkgs/games/steam/fhsenv.nix+16
nixos/modules/programs/steam.nix+8−1
@@ -4,6 +4,13 @@ with lib;
44
55let
66 cfg = config.programs.steam;
7+
8+ steam = pkgs.steam.override {
9+ extraLibraries = pkgs: with config.hardware.opengl;
10+ if pkgs.hostPlatform.is64bit
11+ then [ package ] ++ extraPackages
12+ else [ package32 ] ++ extraPackages32;
13+ };
714in {
815 options.programs.steam.enable = mkEnableOption "steam";
916
@@ -18,7 +25,7 @@ in {
1825
1926 hardware.steam-hardware.enable = true;
2027
21− environment.systemPackages = [ pkgs.steam ];
28+ environment.systemPackages = [ steam steam.run ];
2229 };
2330
2431 meta.maintainers = with maintainers; [ mkg20001 ];
pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix+48−4
@@ -1,4 +1,6 @@
1−{ lib, callPackage, runCommandLocal, writeShellScriptBin, coreutils, bubblewrap }:
1+{ lib, callPackage, runCommandLocal, writeShellScriptBin, glibc, pkgsi686Linux, coreutils, bubblewrap }:
2+
3+let buildFHSEnv = callPackage ./env.nix { }; in
24
35args @ {
46 name
@@ -60,21 +62,45 @@ let
6062 in concatStringsSep "\n "
6163 (map (file: "--ro-bind-try /etc/${file} /etc/${file}") files);
6264
65+ # Create this on the fly instead of linking from /nix
66+ # The container might have to modify it and re-run ldconfig if there are
67+ # issues running some binary with LD_LIBRARY_PATH
68+ createLdConfCache = ''
69+ cat > /etc/ld.so.conf <<EOF
70+ /lib
71+ /lib/x86_64-linux-gnu
72+ /lib64
73+ /usr/lib
74+ /usr/lib/x86_64-linux-gnu
75+ /usr/lib64
76+ /lib/i386-linux-gnu
77+ /lib32
78+ /usr/lib/i386-linux-gnu
79+ /usr/lib32
80+ EOF
81+ ldconfig &> /dev/null
82+ '';
6383 init = run: writeShellScriptBin "${name}-init" ''
6484 source /etc/profile
85+ ${createLdConfCache}
6586 exec ${run} "$@"
6687 '';
6788
6889 bwrapCmd = { initArgs ? "" }: ''
6990 blacklist=(/nix /dev /proc /etc)
7091 ro_mounts=()
92+ symlinks=()
7193 for i in ${env}/*; do
7294 path="/''${i##*/}"
7395 if [[ $path == '/etc' ]]; then
74− continue
96+ :
97+ elif [[ -L $i ]]; then
98+ symlinks+=(--symlink "$(readlink "$i")" "$path")
99+ blacklist+=("$path")
100+ else
101+ ro_mounts+=(--ro-bind "$i" "$path")
102+ blacklist+=("$path")
75103 fi
76− ro_mounts+=(--ro-bind "$i" "$path")
77− blacklist+=("$path")
78104 done
79105
80106 if [[ -d ${env}/etc ]]; then
@@ -112,8 +138,26 @@ let
112138 ${lib.optionalString unshareCgroup "--unshare-cgroup"}
113139 --die-with-parent
114140 --ro-bind /nix /nix
141+ # Our glibc will look for the cache in its own path in `/nix/store`.
142+ # As such, we need a cache to exist there, because pressure-vessel
143+ # depends on the existence of an ld cache. However, adding one
144+ # globally proved to be a bad idea (see #100655), the solution we
145+ # settled on being mounting one via bwrap.
146+ # Also, the cache needs to go to both 32 and 64 bit glibcs, for games
147+ # of both architectures to work.
148+ --tmpfs ${glibc}/etc \
149+ --symlink /etc/ld.so.conf ${glibc}/etc/ld.so.conf \
150+ --symlink /etc/ld.so.cache ${glibc}/etc/ld.so.cache \
151+ --ro-bind ${glibc}/etc/rpc ${glibc}/etc/rpc \
152+ --remount-ro ${glibc}/etc \
153+ --tmpfs ${pkgsi686Linux.glibc}/etc \
154+ --symlink /etc/ld.so.conf ${pkgsi686Linux.glibc}/etc/ld.so.conf \
155+ --symlink /etc/ld.so.cache ${pkgsi686Linux.glibc}/etc/ld.so.cache \
156+ --ro-bind ${pkgsi686Linux.glibc}/etc/rpc ${pkgsi686Linux.glibc}/etc/rpc \
157+ --remount-ro ${pkgsi686Linux.glibc}/etc \
115158 ${etcBindFlags}
116159 "''${ro_mounts[@]}"
160+ "''${symlinks[@]}"
117161 "''${auto_mounts[@]}"
118162 ${init runScript}/bin/${name}-init ${initArgs}
119163 )
pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix+20−3
@@ -1,4 +1,4 @@
1−{ stdenv, buildEnv, writeText, pkgs, pkgsi686Linux }:
1+{ stdenv, lib, buildEnv, writeText, writeShellScriptBin, pkgs, pkgsi686Linux }:
22
33{ name, profile ? ""
44, targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
@@ -49,6 +49,9 @@ let
4949 [ (toString gcc.cc.lib)
5050 ];
5151
52+ ldconfig = writeShellScriptBin "ldconfig" ''
53+ exec ${pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@"
54+ '';
5255 etcProfile = writeText "profile" ''
5356 export PS1='${name}-chrootenv:\u@\h:\w\$ '
5457 export LOCALE_ARCHIVE='/usr/lib/locale/locale-archive'
@@ -86,7 +89,8 @@ let
8689 # Composes a /usr-like directory structure
8790 staticUsrProfileTarget = buildEnv {
8891 name = "${name}-usr-target";
89− paths = [ etcPkg ] ++ basePkgs ++ targetPaths;
92+ # ldconfig wrapper must come first so it overrides the original ldconfig
93+ paths = [ etcPkg ldconfig ] ++ basePkgs ++ targetPaths;
9094 extraOutputsToInstall = [ "out" "lib" "bin" ] ++ extraOutputsToInstall;
9195 ignoreCollisions = true;
9296 };
@@ -132,7 +136,20 @@ let
132136 mkdir -m0755 usr
133137 cd usr
134138 ${setupLibDirs}
135− for i in bin sbin share include; do
139+ ${lib.optionalString isMultiBuild ''
140+ if [ -d "${staticUsrProfileMulti}/share" ]; then
141+ cp -rLf ${staticUsrProfileMulti}/share share
142+ fi
143+ ''}
144+ if [ -d "${staticUsrProfileTarget}/share" ]; then
145+ if [ -d share ]; then
146+ chmod -R 755 share
147+ cp -rLTf ${staticUsrProfileTarget}/share share
148+ else
149+ cp -rLf ${staticUsrProfileTarget}/share share
150+ fi
151+ fi
152+ for i in bin sbin include; do
136153 if [ -d "${staticUsrProfileTarget}/$i" ]; then
137154 cp -rsHf "${staticUsrProfileTarget}/$i" "$i"
138155 fi
pkgs/games/steam/fhsenv.nix+16
@@ -134,6 +134,20 @@ in buildFHSUserEnv rec {
134134 libuuid
135135 libbsd
136136 alsaLib
137+
138+ # needed by getcap for vr startup
139+ libcap
140+
141+ # dependencies for mesa drivers, needed inside pressure-vessel
142+ mesa.drivers
143+ expat
144+ wayland
145+ xlibs.libxcb
146+ xlibs.libXdamage
147+ xlibs.libxshmfence
148+ xlibs.libXxf86vm
149+ llvm_11.lib
150+ libelf
137151 ] ++ (if (!nativeOnly) then [
138152 (steamPackages.steam-runtime-wrapped.override {
139153 inherit runtimeOnly;
@@ -251,6 +265,8 @@ in buildFHSUserEnv rec {
251265 fi
252266
253267 export STEAM_RUNTIME=${if nativeOnly then "0" else "/steamrt"}
268+
269+ export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/intel_icd.x86_64.json:/usr/share/vulkan/icd.d/intel_icd.i686.json:/usr/share/vulkan/icd.d/lvp_icd.x86_64.json:/usr/share/vulkan/icd.d/lvp_icd.i686.json:/usr/share/vulkan/icd.d/nvidia_icd.json:/usr/share/vulkan/icd.d/nvidia_icd32.json:/usr/share/vulkan/icd.d/radeon_icd.x86_64.json:/usr/share/vulkan/icd.d/radeon_icd.i686.json
254270 '' + extraProfile;
255271
256272 runScript = writeScript "steam-wrapper.sh" ''