treewide: rework Steam-shaped fhsenv building (#428815)

authored by K900 and committed by GitHub 72b15f17 0ea51b6a

+239 -338
+31 -31
pkgs/build-support/build-fhsenv-bubblewrap/rootfs-builder/Cargo.lock
··· 1 1 # This file is automatically @generated by Cargo. 2 2 # It is not intended for manual editing. 3 - version = 3 3 + version = 4 4 4 5 5 [[package]] 6 6 name = "anyhow" 7 - version = "1.0.91" 7 + version = "1.0.98" 8 8 source = "registry+https://github.com/rust-lang/crates.io-index" 9 - checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" 9 + checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" 10 10 11 11 [[package]] 12 12 name = "goblin" 13 - version = "0.9.2" 13 + version = "0.10.0" 14 14 source = "registry+https://github.com/rust-lang/crates.io-index" 15 - checksum = "53ab3f32d1d77146981dea5d6b1e8fe31eedcb7013e5e00d6ccd1259a4b4d923" 15 + checksum = "0e961b33649994dcf69303af6b3a332c1228549e604d455d61ec5d2ab5e68d3a" 16 16 dependencies = [ 17 17 "log", 18 18 "plain", ··· 21 21 22 22 [[package]] 23 23 name = "itoa" 24 - version = "1.0.11" 24 + version = "1.0.15" 25 25 source = "registry+https://github.com/rust-lang/crates.io-index" 26 - checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 26 + checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 27 27 28 28 [[package]] 29 29 name = "log" 30 - version = "0.4.22" 30 + version = "0.4.27" 31 31 source = "registry+https://github.com/rust-lang/crates.io-index" 32 - checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" 32 + checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" 33 33 34 34 [[package]] 35 35 name = "memchr" 36 - version = "2.7.4" 36 + version = "2.7.5" 37 37 source = "registry+https://github.com/rust-lang/crates.io-index" 38 - checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 38 + checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" 39 39 40 40 [[package]] 41 41 name = "plain" ··· 45 45 46 46 [[package]] 47 47 name = "proc-macro2" 48 - version = "1.0.89" 48 + version = "1.0.95" 49 49 source = "registry+https://github.com/rust-lang/crates.io-index" 50 - checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" 50 + checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" 51 51 dependencies = [ 52 52 "unicode-ident", 53 53 ] 54 54 55 55 [[package]] 56 56 name = "quote" 57 - version = "1.0.37" 57 + version = "1.0.40" 58 58 source = "registry+https://github.com/rust-lang/crates.io-index" 59 - checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 59 + checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 60 60 dependencies = [ 61 61 "proc-macro2", 62 62 ] ··· 74 74 75 75 [[package]] 76 76 name = "ryu" 77 - version = "1.0.18" 77 + version = "1.0.20" 78 78 source = "registry+https://github.com/rust-lang/crates.io-index" 79 - checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" 79 + checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 80 80 81 81 [[package]] 82 82 name = "same-file" ··· 89 89 90 90 [[package]] 91 91 name = "scroll" 92 - version = "0.12.0" 92 + version = "0.13.0" 93 93 source = "registry+https://github.com/rust-lang/crates.io-index" 94 - checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" 94 + checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add" 95 95 dependencies = [ 96 96 "scroll_derive", 97 97 ] 98 98 99 99 [[package]] 100 100 name = "scroll_derive" 101 - version = "0.12.0" 101 + version = "0.13.0" 102 102 source = "registry+https://github.com/rust-lang/crates.io-index" 103 - checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" 103 + checksum = "22fc4f90c27b57691bbaf11d8ecc7cfbfe98a4da6dbe60226115d322aa80c06e" 104 104 dependencies = [ 105 105 "proc-macro2", 106 106 "quote", ··· 109 109 110 110 [[package]] 111 111 name = "serde" 112 - version = "1.0.213" 112 + version = "1.0.219" 113 113 source = "registry+https://github.com/rust-lang/crates.io-index" 114 - checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" 114 + checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 115 115 dependencies = [ 116 116 "serde_derive", 117 117 ] 118 118 119 119 [[package]] 120 120 name = "serde_derive" 121 - version = "1.0.213" 121 + version = "1.0.219" 122 122 source = "registry+https://github.com/rust-lang/crates.io-index" 123 - checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" 123 + checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 124 124 dependencies = [ 125 125 "proc-macro2", 126 126 "quote", ··· 129 129 130 130 [[package]] 131 131 name = "serde_json" 132 - version = "1.0.132" 132 + version = "1.0.141" 133 133 source = "registry+https://github.com/rust-lang/crates.io-index" 134 - checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" 134 + checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" 135 135 dependencies = [ 136 136 "itoa", 137 137 "memchr", ··· 141 141 142 142 [[package]] 143 143 name = "syn" 144 - version = "2.0.85" 144 + version = "2.0.104" 145 145 source = "registry+https://github.com/rust-lang/crates.io-index" 146 - checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" 146 + checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" 147 147 dependencies = [ 148 148 "proc-macro2", 149 149 "quote", ··· 152 152 153 153 [[package]] 154 154 name = "unicode-ident" 155 - version = "1.0.13" 155 + version = "1.0.18" 156 156 source = "registry+https://github.com/rust-lang/crates.io-index" 157 - checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" 157 + checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 158 158 159 159 [[package]] 160 160 name = "walkdir"
+29 -6
pkgs/build-support/build-fhsenv-bubblewrap/rootfs-builder/src/main.rs
··· 43 43 root_index: usize, 44 44 } 45 45 46 + const FHSENV_MARKER_FILE: &str = "nix-support/is-fhsenv"; 47 + 46 48 fn build_reference_map(refs: Vec<RefGraphNode>) -> HashMap<PathBuf, Vec<PathBuf>> { 47 49 refs.into_iter() 48 50 .map(|mut gn| { ··· 119 121 let mut candidates: HashMap<_, Vec<_>> = HashMap::new(); 120 122 121 123 for (path, priority) in paths { 124 + if path.join(FHSENV_MARKER_FILE).exists() { 125 + // is another fhsenv, skip it 126 + continue; 127 + } 128 + 122 129 for entry in WalkDir::new(&path).follow_links(true) { 123 130 let entry: PathBuf = match entry { 124 131 Ok(ent) => { ··· 134 141 // could be a broken symlink, that's fine, we still want to handle those 135 142 Some(_) => e 136 143 .path() 137 - .ok_or_else(|| anyhow!("I/O error when walking {path:?}"))? 144 + .ok_or_else(|| anyhow!("I/O error when walking {}", path.display()))? 138 145 .into(), 139 146 None => { 140 147 // symlink loop ··· 256 263 .parent() 257 264 .ok_or(anyhow!("destination directory is root")) 258 265 .with_context(|| { 259 - format!("When trying to determine destination directory for {full_dest:?}") 266 + format!( 267 + "When trying to determine destination directory for {}", 268 + full_dest.display() 269 + ) 260 270 })?; 261 271 fs::create_dir_all(dest_dir) 262 - .with_context(|| format!("When trying to create directory {dest_dir:?}"))?; 263 - ufs::symlink(&src, &full_dest) 264 - .with_context(|| format!("When symlinking {src:?} to {full_dest:?}"))?; 272 + .with_context(|| format!("When trying to create directory {}", dest_dir.display()))?; 273 + ufs::symlink(&src, &full_dest).with_context(|| { 274 + format!( 275 + "When symlinking {} to {}", 276 + src.display(), 277 + full_dest.display() 278 + ) 279 + })?; 265 280 } 281 + 282 + let marker = out.join(FHSENV_MARKER_FILE); 283 + fs::create_dir_all( 284 + marker 285 + .parent() 286 + .ok_or(anyhow!("marker file is in root, this should never happen"))?, 287 + )?; 288 + fs::write(marker, [])?; 266 289 267 290 Ok(()) 268 291 } ··· 283 306 284 307 paths = extend_to_closure(paths, &refs)?; 285 308 paths32 = extend_to_closure(paths32, &refs)?; 286 - }; 309 + } 287 310 288 311 let plan = build_plan(paths, paths32)?; 289 312
+2
pkgs/by-name/he/heroic-unwrapped/package.nix
··· 15 15 legendary-heroic, 16 16 nile, 17 17 comet-gog, 18 + umu-launcher, 18 19 }: 19 20 20 21 let ··· 90 91 makeWrapper "${electron}/bin/electron" "$out/bin/heroic" \ 91 92 --inherit-argv0 \ 92 93 --set ELECTRON_FORCE_IS_PACKAGED 1 \ 94 + --suffix PATH ":" "${umu-launcher}/bin" \ 93 95 --add-flags --disable-gpu-compositing \ 94 96 --add-flags $out/opt/heroic/resources/app.asar \ 95 97 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"
+5 -143
pkgs/by-name/he/heroic/package.nix
··· 1 1 { 2 - buildFHSEnv, 2 + steam, 3 3 heroic-unwrapped, 4 4 extraPkgs ? pkgs: [ ], 5 5 extraLibraries ? pkgs: [ ], 6 6 }: 7 7 8 - buildFHSEnv { 8 + steam.buildRuntimeEnv { 9 9 pname = "heroic"; 10 - inherit (heroic-unwrapped) version; 10 + inherit (heroic-unwrapped) version meta; 11 11 12 12 runScript = "heroic"; 13 13 14 - # Many Wine and native games need 32-bit libraries. 15 - multiArch = true; 16 - 17 - # required by Electron 18 - unshareIpc = false; 19 - 20 - targetPkgs = 21 - pkgs: 22 - with pkgs; 23 - [ 24 - heroic-unwrapped 25 - gamemode 26 - curl 27 - gawk 28 - zenity 29 - kdePackages.kdialog 30 - mangohud 31 - net-tools 32 - opencl-headers 33 - p7zip 34 - pciutils 35 - perl 36 - psmisc 37 - python3 38 - umu-launcher 39 - unzip 40 - which 41 - xorg.xrandr 42 - zstd 43 - ] 44 - ++ extraPkgs pkgs; 45 - 46 - multiPkgs = 47 - let 48 - xorgDeps = 49 - pkgs: with pkgs.xorg; [ 50 - libICE 51 - libpthreadstubs 52 - libSM 53 - libX11 54 - libXaw 55 - libxcb 56 - libXcomposite 57 - libXcursor 58 - libXdmcp 59 - libXext 60 - libXfixes 61 - libXi 62 - libXinerama 63 - libXmu 64 - libXrandr 65 - libXrender 66 - libXScrnSaver 67 - libXt 68 - libXtst 69 - libXv 70 - libXxf86vm 71 - ]; 72 - gstreamerDeps = 73 - pkgs: with pkgs.gst_all_1; [ 74 - gstreamer 75 - gst-plugins-base 76 - gst-plugins-good 77 - gst-plugins-ugly 78 - gst-plugins-bad 79 - gst-libav 80 - ]; 81 - in 82 - pkgs: 83 - with pkgs; 84 - [ 85 - alsa-lib 86 - alsa-plugins 87 - bash 88 - cabextract 89 - cairo 90 - coreutils 91 - cups 92 - dbus 93 - freealut 94 - freetype 95 - fribidi 96 - giflib 97 - glib 98 - gnutls 99 - gtk3 100 - icu 101 - lcms2 102 - libevdev 103 - libgcrypt 104 - libGLU 105 - libglvnd 106 - libgpg-error 107 - libgudev 108 - libjpeg 109 - libkrb5 110 - libmpeg2 111 - libogg 112 - libopus 113 - libpng 114 - libpulseaudio 115 - libselinux 116 - libsndfile 117 - libtheora 118 - libtiff 119 - libunwind 120 - libusb1 121 - libv4l 122 - libva 123 - libvdpau 124 - libvorbis 125 - libvpx 126 - libwebp 127 - libxkbcommon 128 - libxml2 129 - mpg123 130 - ncurses 131 - ocl-icd 132 - openal 133 - openldap 134 - openssl 135 - pango 136 - pipewire 137 - samba4 138 - sane-backends 139 - SDL2 140 - speex 141 - sqlite 142 - udev 143 - unixODBC 144 - util-linux 145 - vulkan-loader 146 - wayland 147 - zlib 148 - ] 149 - ++ xorgDeps pkgs 150 - ++ gstreamerDeps pkgs 151 - ++ extraLibraries pkgs; 14 + extraPkgs = pkgs: [ heroic-unwrapped ] ++ extraPkgs pkgs; 15 + inherit extraLibraries; 152 16 153 17 extraInstallCommands = '' 154 18 mkdir -p $out/share 155 19 ln -s ${heroic-unwrapped}/share/applications $out/share 156 20 ln -s ${heroic-unwrapped}/share/icons $out/share 157 21 ''; 158 - 159 - meta = heroic-unwrapped.meta; 160 22 }
+159 -129
pkgs/by-name/st/steam/package.nix
··· 13 13 privateTmp ? true, # if the steam bubblewrap should isolate /tmp 14 14 }: 15 15 let 16 - steamEnv = 16 + buildRuntimeEnv = 17 17 { 18 - name, 19 - runScript, 20 - passthru ? { }, 21 - meta ? { }, 22 - }: 23 - buildFHSEnv { 24 - inherit 25 - name 26 - runScript 27 - passthru 28 - meta 29 - privateTmp 30 - ; 31 - 32 - multiArch = true; 33 - includeClosures = true; 34 - 35 - # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#command-line-tools 36 - targetPkgs = 37 - pkgs: 38 - with pkgs; 39 - [ 40 - steam-unwrapped 18 + extraPkgs ? pkgs: [ ], 19 + extraLibraries ? pkgs: [ ], 20 + extraProfile ? "", 21 + extraPreBwrapCmds ? "", 22 + extraBwrapArgs ? [ ], 23 + extraEnv ? { }, 24 + ... 25 + }@args: 26 + buildFHSEnv ( 27 + (builtins.removeAttrs args [ 28 + "extraPkgs" 29 + "extraLibraries" 30 + "extraProfile" 31 + "extraPreBwrapCmds" 32 + "extraBwrapArgs" 33 + "extraArgs" 34 + "extraEnv" 35 + ]) 36 + // { 37 + inherit privateTmp; 41 38 42 - bash 43 - coreutils 44 - file 45 - lsb-release # not documented, called from Big Picture 46 - pciutils # not documented, complains about lspci on startup 47 - glibc_multi.bin 48 - xdg-utils # calls xdg-open occasionally 49 - xz 50 - zenity 39 + multiArch = true; 40 + includeClosures = true; 51 41 52 - # Steam expects it to be /sbin specifically 53 - (pkgs.runCommand "sbin-ldconfig" { } '' 54 - mkdir -p $out/sbin 55 - ln -s /bin/ldconfig $out/sbin/ldconfig 56 - '') 42 + # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#command-line-tools 43 + targetPkgs = 44 + pkgs: 45 + with pkgs; 46 + [ 47 + bash 48 + coreutils 49 + file 50 + lsb-release # not documented, called from Big Picture 51 + pciutils # not documented, complains about lspci on startup 52 + glibc_multi.bin 53 + xdg-utils # calls xdg-open occasionally 54 + xz 55 + zenity 57 56 58 - # crashes on startup if it can't find libX11 locale files 59 - (pkgs.runCommand "xorg-locale" { } '' 60 - mkdir -p $out 61 - ln -s ${xorg.libX11}/share $out/share 62 - '') 63 - ] 64 - ++ extraPkgs pkgs; 57 + # Steam expects it to be /sbin specifically 58 + (pkgs.runCommand "sbin-ldconfig" { } '' 59 + mkdir -p $out/sbin 60 + ln -s /bin/ldconfig $out/sbin/ldconfig 61 + '') 65 62 66 - # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#shared-libraries 67 - multiPkgs = 68 - pkgs: 69 - with pkgs; 70 - [ 71 - glibc 72 - libxcrypt 73 - libGL 63 + # crashes on startup if it can't find libX11 locale files 64 + (pkgs.runCommand "xorg-locale" { } '' 65 + mkdir -p $out 66 + ln -s ${xorg.libX11}/share $out/share 67 + '') 68 + ] 69 + ++ extraPkgs pkgs; 74 70 75 - libdrm 76 - libgbm 77 - udev 78 - libudev0-shim 79 - libva 80 - vulkan-loader 71 + # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#shared-libraries 72 + multiPkgs = 73 + pkgs: 74 + with pkgs; 75 + [ 76 + glibc 77 + libxcrypt 78 + libGL 81 79 82 - networkmanager 83 - # not documented, used for network status things in Big Picture 84 - # FIXME: figure out how to only build libnm? 85 - libcap # not documented, required by srt-bwrap 86 - ] 87 - ++ extraLibraries pkgs; 80 + libdrm 81 + libgbm 82 + udev 83 + libudev0-shim 84 + libva 85 + vulkan-loader 88 86 89 - extraInstallCommands = lib.optionalString (steam-unwrapped != null) '' 90 - ln -s ${steam-unwrapped}/share $out/share 91 - ''; 87 + networkmanager 88 + # not documented, used for network status things in Big Picture 89 + # FIXME: figure out how to only build libnm? 90 + libcap # not documented, required by srt-bwrap 91 + ] 92 + ++ extraLibraries pkgs; 92 93 93 - profile = '' 94 - # prevents log spam from SteamRT GTK trying to load host GIO modules 95 - unset GIO_EXTRA_MODULES 94 + profile = '' 95 + # prevents log spam from SteamRT GTK trying to load host GIO modules 96 + unset GIO_EXTRA_MODULES 96 97 97 - # udev event notifications don't work reliably inside containers. 98 - # SDL2 already tries to automatically detect flatpak and pressure-vessel 99 - # and falls back to inotify-based discovery [1]. We make SDL2 do the 100 - # same by telling it explicitly. 101 - # 102 - # [1] <https://github.com/libsdl-org/SDL/commit/8e2746cfb6e1f1a1da5088241a1440fd2535e321> 103 - export SDL_JOYSTICK_DISABLE_UDEV=1 98 + # udev event notifications don't work reliably inside containers. 99 + # SDL2 already tries to automatically detect flatpak and pressure-vessel 100 + # and falls back to inotify-based discovery [1]. We make SDL2 do the 101 + # same by telling it explicitly. 102 + # 103 + # [1] <https://github.com/libsdl-org/SDL/commit/8e2746cfb6e1f1a1da5088241a1440fd2535e321> 104 + export SDL_JOYSTICK_DISABLE_UDEV=1 104 105 105 - # This is needed for IME (e.g. iBus, fcitx5) to function correctly on non-CJK locales 106 - # https://github.com/ValveSoftware/steam-for-linux/issues/781#issuecomment-2004757379 107 - export GTK_IM_MODULE='xim' 106 + # This is needed for IME (e.g. iBus, fcitx5) to function correctly on non-CJK locales 107 + # https://github.com/ValveSoftware/steam-for-linux/issues/781#issuecomment-2004757379 108 + export GTK_IM_MODULE='xim' 108 109 109 - # See https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#graphics-driver 110 - export LIBGL_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri 111 - export __EGL_VENDOR_LIBRARY_DIRS=/run/opengl-driver/share/glvnd/egl_vendor.d:/run/opengl-driver-32/share/glvnd/egl_vendor.d 112 - export LIBVA_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri 113 - export VDPAU_DRIVER_PATH=/run/opengl-driver/lib/vdpau:/run/opengl-driver-32/lib/vdpau 110 + # See https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#graphics-driver 111 + export LIBGL_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri 112 + export __EGL_VENDOR_LIBRARY_DIRS=/run/opengl-driver/share/glvnd/egl_vendor.d:/run/opengl-driver-32/share/glvnd/egl_vendor.d 113 + export LIBVA_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri 114 + export VDPAU_DRIVER_PATH=/run/opengl-driver/lib/vdpau:/run/opengl-driver-32/lib/vdpau 114 115 115 - # Steam gets confused by the symlinks to bind mounts to symlinks /etc/localtime ends up being, so help it out. 116 - # See also: https://github.com/flathub/com.valvesoftware.Steam/blob/28481f09f33c12b6ac7421d13af9ed1523c54ec4/steam_wrapper/steam_wrapper.py#L160 117 - if [ -z ''${TZ+x} ]; then 118 - new_TZ="$(readlink -f /etc/localtime | grep -P -o '(?<=/zoneinfo/).*$')" 119 - if [ $? -eq 0 ]; then 120 - export TZ="$new_TZ" 116 + # Steam gets confused by the symlinks to bind mounts to symlinks /etc/localtime ends up being, so help it out. 117 + # See also: https://github.com/flathub/com.valvesoftware.Steam/blob/28481f09f33c12b6ac7421d13af9ed1523c54ec4/steam_wrapper/steam_wrapper.py#L160 118 + if [ -z ''${TZ+x} ]; then 119 + new_TZ="$(readlink -f /etc/localtime | grep -P -o '(?<=/zoneinfo/).*$')" 120 + if [ $? -eq 0 ]; then 121 + export TZ="$new_TZ" 122 + fi 121 123 fi 122 - fi 123 124 124 - set -a 125 - ${lib.toShellVars extraEnv} 126 - set +a 125 + set -a 126 + ${lib.toShellVars extraEnv} 127 + set +a 127 128 128 - ${extraProfile} 129 - ''; 129 + ${extraProfile} 130 + ''; 130 131 131 - inherit extraPreBwrapCmds; 132 + inherit extraPreBwrapCmds; 132 133 133 - extraBwrapArgs = [ 134 - # Steam will dump crash reports here, make those more accessible 135 - "--bind-try /tmp/dumps /tmp/dumps" 136 - ] 137 - ++ extraBwrapArgs; 138 - }; 134 + extraBwrapArgs = [ 135 + # Steam will dump crash reports here, make those more accessible 136 + "--bind-try /tmp/dumps /tmp/dumps" 137 + ] 138 + ++ extraBwrapArgs; 139 + } 140 + ); 139 141 in 140 - steamEnv { 141 - name = "steam"; 142 + buildRuntimeEnv { 143 + pname = "steam"; 144 + inherit (steam-unwrapped) version meta; 145 + 146 + extraPkgs = pkgs: [ steam-unwrapped ] ++ extraPkgs pkgs; 147 + inherit 148 + extraLibraries 149 + extraProfile 150 + extraPreBwrapCmds 151 + extraBwrapArgs 152 + extraEnv 153 + ; 142 154 143 155 runScript = writeShellScript "steam-wrapped" '' 144 156 exec steam ${extraArgs} "$@" 145 157 ''; 146 158 147 - passthru.run = steamEnv { 148 - name = "steam-run"; 159 + extraInstallCommands = '' 160 + ln -s ${steam-unwrapped}/share $out/share 161 + ''; 149 162 150 - runScript = writeShellScript "steam-run" '' 151 - if [ $# -eq 0 ]; then 152 - echo "Usage: steam-run command-to-run args..." >&2 153 - exit 1 154 - fi 163 + passthru = 164 + let 165 + makeSteamRun = 166 + package: 167 + buildRuntimeEnv { 168 + name = "steam-run"; 155 169 156 - exec "$@" 157 - ''; 170 + extraPkgs = pkgs: package ++ extraPkgs pkgs; 158 171 159 - meta = (steam-unwrapped.meta or { }) // { 160 - description = "Run commands in the same FHS environment that is used for Steam"; 161 - mainProgram = "steam-run"; 162 - name = "steam-run"; 163 - # steam-run itself is just a script that lives in nixpkgs (which is licensed under MIT). 164 - # steam is a dependency and already unfree, so normal steam-run will not install without 165 - # allowing unfree packages or appropriate `allowUnfreePredicate` rules. 166 - license = lib.licenses.mit; 167 - }; 168 - }; 172 + inherit 173 + extraLibraries 174 + extraProfile 175 + extraPreBwrapCmds 176 + extraBwrapArgs 177 + extraEnv 178 + ; 169 179 170 - meta = (steam-unwrapped.meta or { }) // { 171 - description = "Steam dependencies (dummy package, do not use)"; 172 - }; 180 + runScript = writeShellScript "steam-run" '' 181 + if [ $# -eq 0 ]; then 182 + echo "Usage: steam-run command-to-run args..." >&2 183 + exit 1 184 + fi 185 + 186 + exec "$@" 187 + ''; 188 + 189 + meta = { 190 + description = "Run commands in the same FHS environment that is used for Steam"; 191 + mainProgram = "steam-run"; 192 + name = "steam-run"; 193 + license = lib.licenses.mit; 194 + }; 195 + }; 196 + in 197 + { 198 + inherit buildRuntimeEnv; 199 + 200 + run = makeSteamRun [ steam-unwrapped ]; 201 + run-free = makeSteamRun [ ]; 202 + }; 173 203 }
+12 -24
pkgs/by-name/um/umu-launcher/package.nix
··· 1 1 { 2 - buildFHSEnv, 3 2 lib, 4 3 steam, 5 4 umu-launcher-unwrapped, ··· 7 6 extraLibraries ? pkgs: [ ], 8 7 extraProfile ? "", # string to append to shell profile 9 8 extraEnv ? { }, # Environment variables to include in shell profile 10 - withMultiArch ? true, # Many Wine games need 32-bit libraries. 11 9 }: 12 - let 13 - # Steam is not a dependency, but we re-use some of its implementation 14 - steam' = steam.override { 15 - inherit extraEnv extraProfile; 16 - }; 17 - in 18 - buildFHSEnv { 10 + steam.buildRuntimeEnv { 19 11 pname = "umu-launcher"; 20 12 inherit (umu-launcher-unwrapped) version meta; 21 13 22 - targetPkgs = 23 - pkgs: 24 - [ 25 - # Use umu-launcher-unwrapped from the package args, to support overriding 26 - umu-launcher-unwrapped 27 - ] 28 - ++ extraPkgs pkgs; 29 - multiPkgs = extraLibraries; 30 - multiArch = withMultiArch; 14 + extraPkgs = pkgs: [ umu-launcher-unwrapped ] ++ extraPkgs pkgs; 15 + inherit 16 + extraLibraries 17 + extraProfile 18 + extraEnv 19 + ; 31 20 32 21 executableName = umu-launcher-unwrapped.meta.mainProgram; 33 22 runScript = lib.getExe umu-launcher-unwrapped; 34 23 24 + # Legendary spawns UMU, doesn't wait for it to exit, 25 + # and immediately exits itself. This makes it so we can't 26 + # die with parent, because parent is already dead. 27 + dieWithParent = false; 28 + 35 29 extraInstallCommands = '' 36 30 ln -s ${umu-launcher-unwrapped}/lib $out/lib 37 31 ln -s ${umu-launcher-unwrapped}/share $out/share 38 32 ''; 39 - 40 - # For umu & proton, we need roughly the same environment as Steam. 41 - # For simplicity, we use Steam's `profile` implementation. 42 - # See https://github.com/NixOS/nixpkgs/pull/381047 43 - # And https://github.com/NixOS/nixpkgs/issues/297662#issuecomment-2647656699 44 - inherit (steam'.args) profile; 45 33 }
+1 -5
pkgs/top-level/all-packages.nix
··· 14918 14918 springLobby = callPackage ../games/spring/springlobby.nix { }; 14919 14919 14920 14920 steam-run = steam.run; 14921 - 14922 - # This exists so Hydra tries to build all of Steam's dependencies. 14923 - steam-fhsenv-without-steam = steam.override { steam-unwrapped = null; }; 14924 - 14925 - steam-run-free = steam-fhsenv-without-steam.run; 14921 + steam-run-free = steam.run-free; 14926 14922 14927 14923 steamback = python3.pkgs.callPackage ../tools/games/steamback { }; 14928 14924