git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #114024 from LuigiPiucco/pressure-vessel
cdcaafcBernardo Meurer
nixos/modules/programs/steam.nix+8−1
@@ -4,6 +4,13 @@ with lib;
4
4
5let
5let
6 cfg = config.programs.steam;
6 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+ };
7in {
14in {
8 options.programs.steam.enable = mkEnableOption "steam";
15 options.programs.steam.enable = mkEnableOption "steam";
9
16
@@ -18,7 +25,7 @@ in {
18
25
19 hardware.steam-hardware.enable = true;
26 hardware.steam-hardware.enable = true;
20
27
21− environment.systemPackages = [ pkgs.steam ];
28+ environment.systemPackages = [ steam steam.run ];
22 };
29 };
23
30
24 meta.maintainers = with maintainers; [ mkg20001 ];
31 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
2
4
3args @ {
5args @ {
4 name
6 name
@@ -60,21 +62,45 @@ let
60 in concatStringsSep "\n "
62 in concatStringsSep "\n "
61 (map (file: "--ro-bind-try /etc/${file} /etc/${file}") files);
63 (map (file: "--ro-bind-try /etc/${file} /etc/${file}") files);
62
64
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+ '';
63 init = run: writeShellScriptBin "${name}-init" ''
83 init = run: writeShellScriptBin "${name}-init" ''
64 source /etc/profile
84 source /etc/profile
85+ ${createLdConfCache}
65 exec ${run} "$@"
86 exec ${run} "$@"
66 '';
87 '';
67
88
68 bwrapCmd = { initArgs ? "" }: ''
89 bwrapCmd = { initArgs ? "" }: ''
69 blacklist=(/nix /dev /proc /etc)
90 blacklist=(/nix /dev /proc /etc)
70 ro_mounts=()
91 ro_mounts=()
92+ symlinks=()
71 for i in ${env}/*; do
93 for i in ${env}/*; do
72 path="/''${i##*/}"
94 path="/''${i##*/}"
73 if [[ $path == '/etc' ]]; then
95 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")
75 fi
103 fi
76− ro_mounts+=(--ro-bind "$i" "$path")
77− blacklist+=("$path")
78 done
104 done
79
105
80 if [[ -d ${env}/etc ]]; then
106 if [[ -d ${env}/etc ]]; then
@@ -112,8 +138,26 @@ let
112 ${lib.optionalString unshareCgroup "--unshare-cgroup"}
138 ${lib.optionalString unshareCgroup "--unshare-cgroup"}
113 --die-with-parent
139 --die-with-parent
114 --ro-bind /nix /nix
140 --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 \
115 ${etcBindFlags}
158 ${etcBindFlags}
116 "''${ro_mounts[@]}"
159 "''${ro_mounts[@]}"
160+ "''${symlinks[@]}"
117 "''${auto_mounts[@]}"
161 "''${auto_mounts[@]}"
118 ${init runScript}/bin/${name}-init ${initArgs}
162 ${init runScript}/bin/${name}-init ${initArgs}
119 )
163 )
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 }:
2
2
3{ name, profile ? ""
3{ name, profile ? ""
4, targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
4, targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
@@ -49,6 +49,9 @@ let
49 [ (toString gcc.cc.lib)
49 [ (toString gcc.cc.lib)
50 ];
50 ];
51
51
52+ ldconfig = writeShellScriptBin "ldconfig" ''
53+ exec ${pkgs.glibc.bin}/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache "$@"
54+ '';
52 etcProfile = writeText "profile" ''
55 etcProfile = writeText "profile" ''
53 export PS1='${name}-chrootenv:\u@\h:\w\$ '
56 export PS1='${name}-chrootenv:\u@\h:\w\$ '
54 export LOCALE_ARCHIVE='/usr/lib/locale/locale-archive'
57 export LOCALE_ARCHIVE='/usr/lib/locale/locale-archive'
@@ -86,7 +89,8 @@ let
86 # Composes a /usr-like directory structure
89 # Composes a /usr-like directory structure
87 staticUsrProfileTarget = buildEnv {
90 staticUsrProfileTarget = buildEnv {
88 name = "${name}-usr-target";
91 name = "${name}-usr-target";
92+ # ldconfig wrapper must come first so it overrides the original ldconfig
89− paths = [ etcPkg ] ++ basePkgs ++ targetPaths;
93+ paths = [ etcPkg ldconfig ] ++ basePkgs ++ targetPaths;
90 extraOutputsToInstall = [ "out" "lib" "bin" ] ++ extraOutputsToInstall;
94 extraOutputsToInstall = [ "out" "lib" "bin" ] ++ extraOutputsToInstall;
91 ignoreCollisions = true;
95 ignoreCollisions = true;
92 };
96 };
@@ -132,7 +136,20 @@ let
132 mkdir -m0755 usr
136 mkdir -m0755 usr
133 cd usr
137 cd usr
134 ${setupLibDirs}
138 ${setupLibDirs}
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
135− for i in bin sbin share include; do
152+ for i in bin sbin include; do
136 if [ -d "${staticUsrProfileTarget}/$i" ]; then
153 if [ -d "${staticUsrProfileTarget}/$i" ]; then
137 cp -rsHf "${staticUsrProfileTarget}/$i" "$i"
154 cp -rsHf "${staticUsrProfileTarget}/$i" "$i"
138 fi
155 fi
pkgs/games/steam/fhsenv.nix+16
@@ -134,6 +134,20 @@ in buildFHSUserEnv rec {
134 libuuid
134 libuuid
135 libbsd
135 libbsd
136 alsaLib
136 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
137 ] ++ (if (!nativeOnly) then [
151 ] ++ (if (!nativeOnly) then [
138 (steamPackages.steam-runtime-wrapped.override {
152 (steamPackages.steam-runtime-wrapped.override {
139 inherit runtimeOnly;
153 inherit runtimeOnly;
@@ -251,6 +265,8 @@ in buildFHSUserEnv rec {
251 fi
265 fi
252
266
253 export STEAM_RUNTIME=${if nativeOnly then "0" else "/steamrt"}
267 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
254 '' + extraProfile;
270 '' + extraProfile;
255
271
256 runScript = writeScript "steam-wrapper.sh" ''
272 runScript = writeScript "steam-wrapper.sh" ''