summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2015-08-23 18:17:15 +0300
committerNikolay Amiantov <ab@fmap.me>2015-10-11 17:57:31 +0300
commit6c9ee645ec0fb4a140ddf70525ea15df6d1827c7 (patch)
treea3b77da881a5c765f88b77f5d27177ca00b00d57 /pkgs/games
parent8b034964d1e8aca285f601680634130fc954070c (diff)
downloadnixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.tar
nixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.tar.gz
nixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.tar.bz2
nixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.tar.lz
nixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.tar.xz
nixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.tar.zst
nixpkgs-6c9ee645ec0fb4a140ddf70525ea15df6d1827c7.zip
steam: add steamPackages namespace, build our own runtime
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/steam/build-runtime.sh47
-rw-r--r--pkgs/games/steam/chrootenv.nix122
-rw-r--r--pkgs/games/steam/default.nix43
-rw-r--r--pkgs/games/steam/runtime-wrapped.nix109
-rw-r--r--pkgs/games/steam/steam.nix38
5 files changed, 213 insertions, 146 deletions
diff --git a/pkgs/games/steam/build-runtime.sh b/pkgs/games/steam/build-runtime.sh
new file mode 100644
index 00000000000..ddf974671a0
--- /dev/null
+++ b/pkgs/games/steam/build-runtime.sh
@@ -0,0 +1,47 @@
+source $stdenv/setup
+
+outp=$out/lib/steam-runtime
+
+buildDir() {
+  paths="$1"
+  pkgs="$2"
+
+  for pkg in $pkgs; do
+    echo "adding package $pkg"
+    for path in $paths; do
+      if [ -d $pkg/$path ]; then
+        cd $pkg/$path
+        for file in *; do
+          found=""
+          for i in $paths; do
+            if [ -e "$outp/$i/$file" ]; then
+              found=1
+              break
+            fi
+          done
+          if [ -z "$found" ]; then
+            mkdir -p $outp/$path
+            ln -s "$pkg/$path/$file" $outp/$path
+            sovers=$(echo $file | perl -ne 'print if s/.*?\.so\.(.*)/\1/')
+            if [ ! -z "$sovers" ]; then
+              fname=''${file%.''${sovers}}
+              for ver in ''${sovers//./ }; do
+                found=""
+                for i in $paths; do
+                  if [ -e "$outp/$i/$fname" ]; then
+                    found=1
+                    break
+                  fi
+                done
+                [ -n "$found" ] || ln -s "$pkg/$path/$file" "$outp/$path/$fname"
+                fname="$fname.$ver"
+              done
+            fi
+          fi
+        done
+      fi
+    done
+  done
+}
+
+eval "$installPhase"
diff --git a/pkgs/games/steam/chrootenv.nix b/pkgs/games/steam/chrootenv.nix
index bb459d16819..cbf5b92760b 100644
--- a/pkgs/games/steam/chrootenv.nix
+++ b/pkgs/games/steam/chrootenv.nix
@@ -1,14 +1,13 @@
-{ lib, buildFHSUserEnv, steam-runtime
-, withRuntime ? false
-, withJava    ? false
-, withPrimus  ? false
+{ lib, buildFHSUserEnv
+, withJava   ? false
+, withPrimus ? false
 }:
 
 buildFHSUserEnv {
   name = "steam";
 
   targetPkgs = pkgs: with pkgs; [
-      steam-original
+      steamPackages.steam
       # Errors in output without those
       pciutils
       python2
@@ -31,125 +30,24 @@ buildFHSUserEnv {
       xlibs.libX11
       xlibs.libXfixes
 
-      glib
-      gtk2
-      bzip2
-      zlib
-      libpulseaudio
-      gdk_pixbuf
-
       # Not formally in runtime but needed by some games
       gst_all_1.gstreamer
       gst_all_1.gst-plugins-ugly
-    ] ++ lib.optionals withRuntime [
-      # Without these it silently fails
-      xlibs.libXinerama
-      xlibs.libXdamage
-      xlibs.libXcursor
-      xlibs.libXrender
-      xlibs.libXScrnSaver
-      xlibs.libXi
-      xlibs.libSM
-      xlibs.libICE
-      gnome2.GConf
-      freetype
-      openalSoft
-      curl
-      nspr
-      nss
-      fontconfig
-      cairo
-      pango
-      alsaLib
-      expat
-      dbus
-      cups
-      libcap
-      SDL2
-      libusb1
-      dbus_glib
-      libav
-      atk
-      # Only libraries are needed from those two
-      udev182
-      networkmanager098
-
-      # Verified games requirements
-      xlibs.libXmu
-      xlibs.libxcb
-      xlibs.libpciaccess
-      mesa_glu
-      libuuid
-      libogg
-      libvorbis
-      SDL
-      SDL2_image
-      glew110
-      openssl
-      libidn
 
-      # Other things from runtime
-      xlibs.libXinerama
-      flac
-      freeglut
-      libjpeg
-      libpng12
-      libsamplerate
-      libmikmod
-      libtheora
-      pixman
-      speex
-      SDL_image
-      SDL_ttf
-      SDL_mixer
-      SDL2_net
-      SDL2_ttf
-      SDL2_mixer
-      gstreamer
-      gst_plugins_base
+      steamPackages.steam-runtime-wrapped
     ];
 
   extraBuildCommands = ''
     [ -d lib64 ] && mv lib64/steam lib
 
-    # FIXME: maybe we should replace this with proper libcurl-gnutls
-    ln -s libcurl.so.4 lib/libcurl-gnutls.so.4
-    [ -d lib64 ] && ln -s libcurl.so.4 lib64/libcurl-gnutls.so.4
-  '' + lib.optionals withRuntime ''
-    mkdir -p    steamrt/usr
-    ln -s lib32 steamrt/lib
-
-    if [ -d lib64 ]; then
-      ln -s                    ${steam-runtime}/i386/usr/bin     steamrt/bin
-    else
-      ln -s                    ${steam-runtime}/amd64/usr/bin    steamrt/bin
-    fi
-
-    ln -s                      ${steam-runtime}/i386/etc         steamrt/etc
-    ln -s                      ${steam-runtime}/i386/usr/include steamrt/usr/include
-
-    cp -rsf --no-preserve mode ${steam-runtime}/i386/usr/lib     steamrt/lib32
-    cp -rsf                    ${steam-runtime}/i386/lib/*       steamrt/lib32
-
-    cp -rsf --no-preserve mode ${steam-runtime}/amd64/usr/lib    steamrt/lib64
-    cp -rsf                    ${steam-runtime}/amd64/lib/*      steamrt/lib64
-
-    libs=$(ls -dm --quoting-style=escape steamrt/lib{32,64}/{,*/})
+    mkdir -p steamrt
 
-    echo    'export STEAM_RUNTIME=0'                    >  steamrt/profile
-    echo    'export PATH=$PATH:/steamrt/bin'            >> steamrt/profile
-    echo -n 'export LD_LIBRARY_PATH=/'                  >> steamrt/profile
-    echo -n $libs | sed 's/\/, /:\//g' | sed 's/\/$//g' >> steamrt/profile
-    echo    ':$LD_LIBRARY_PATH'                         >> steamrt/profile
+    ln -s ../lib64/steam-runtime steamrt/amd64
+    ln -s ../lib/steam-runtime steamrt/i386
   '';
 
-  profile = if withRuntime then ''
-    source /steamrt/profile
-  '' else ''
-    # Ugly workaround for https://github.com/ValveSoftware/steam-for-linux/issues/3504
-    export LD_PRELOAD=/lib32/libpulse.so:/lib64/libpulse.so:/lib32/libasound.so:/lib64/libasound.so:$LD_PRELOAD
-    # Another one for https://github.com/ValveSoftware/steam-for-linux/issues/3801
-    export LD_PRELOAD=/lib32/libstdc++.so:/lib64/libstdc++.so:$LD_PRELOAD
+  profile = ''
+    export STEAM_RUNTIME=/steamrt
   '';
 
   runScript = "steam";
diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix
index 2f2ce921176..c2a28a53ae6 100644
--- a/pkgs/games/steam/default.nix
+++ b/pkgs/games/steam/default.nix
@@ -1,38 +1,13 @@
-{stdenv, fetchurl, traceDeps ? false}:
+{ pkgs, newScope }:
 
-stdenv.mkDerivation rec {
-  name = "${program}-original-${version}";
-  program = "steam";
-  version = "1.0.0.49";
+let
+  callPackage = newScope self;
 
-  src = fetchurl {
-    url = "http://repo.steampowered.com/steam/pool/steam/s/steam/${program}_${version}.tar.gz";
-    sha256 = "1c1gl5pwvb5gnnnqf5d9hpcjnfjjgmn4lgx8v0fbx1am5xf3p2gx";
+  self = rec {
+    steam-runtime = callPackage ./runtime.nix { };
+    steam-runtime-wrapped = callPackage ./runtime-wrapped.nix { };
+    steam = callPackage ./steam.nix { };
+    steam-chrootenv = callPackage ./chrootenv.nix { };
   };
 
-  traceLog = "/tmp/steam-trace-dependencies.log";
-
-  installPhase = ''
-    make DESTDIR=$out install
-    mv $out/usr/* $out #*/
-    rmdir $out/usr
-
-    rm $out/bin/steamdeps
-    ${stdenv.lib.optionalString traceDeps ''
-      cat > $out/bin/steamdeps <<EOF
-      #! /bin/bash
-      echo \$1 >> ${traceLog}
-      cat \$1 >> ${traceLog}
-      echo >> ${traceLog}
-      EOF
-      chmod +x $out/bin/steamdeps
-    ''}
-  '';
-
-  meta = with stdenv.lib; {
-    description = "A digital distribution platform";
-    homepage = http://store.steampowered.com/;
-    license = licenses.unfree;
-    maintainers = with maintainers; [ jagajaga ];
-  };
-}
+in self
diff --git a/pkgs/games/steam/runtime-wrapped.nix b/pkgs/games/steam/runtime-wrapped.nix
new file mode 100644
index 00000000000..238626c4ab4
--- /dev/null
+++ b/pkgs/games/steam/runtime-wrapped.nix
@@ -0,0 +1,109 @@
+{ stdenv, perl, pkgs, steam-runtime
+, nativeOnly ? false
+, runtimeOnly ? false
+}:
+
+assert !(nativeOnly && runtimeOnly);
+
+let 
+  runtimePkgs = with pkgs; [
+    # Required
+    glib
+    gtk2
+    bzip2
+    zlib
+    gdk_pixbuf
+
+    # Without these it silently fails
+    xlibs.libXinerama
+    xlibs.libXdamage
+    xlibs.libXcursor
+    xlibs.libXrender
+    xlibs.libXScrnSaver
+    xlibs.libXi
+    xlibs.libSM
+    xlibs.libICE
+    gnome2.GConf
+    freetype
+    curl
+    nspr
+    nss
+    fontconfig
+    cairo
+    pango
+    expat
+    dbus
+    cups
+    libcap
+    SDL2
+    libusb1
+    dbus_glib
+    libav
+    atk
+    # Only libraries are needed from those two
+    udev182
+    networkmanager098
+
+    # Verified games requirements
+    xlibs.libXmu
+    xlibs.libxcb
+    xlibs.libpciaccess
+    mesa_glu
+    libuuid
+    libogg
+    libvorbis
+    SDL
+    SDL2_image
+    glew110
+    openssl
+    libidn
+
+    # Other things from runtime
+    xlibs.libXinerama
+    flac
+    freeglut
+    libjpeg
+    libpng12
+    libsamplerate
+    libmikmod
+    libtheora
+    pixman
+    speex
+    SDL_image
+    SDL_ttf
+    SDL_mixer
+    SDL2_net
+    SDL2_ttf
+    SDL2_mixer
+    gstreamer
+    gst_plugins_base
+  ];
+
+  overridePkgs = with pkgs; [
+    gcc48.cc # libstdc++
+    libpulseaudio
+    alsaLib
+    openalSoft
+  ];
+
+  ourRuntime = if runtimeOnly then []
+               else if nativeOnly then runtimePkgs ++ overridePkgs
+               else overridePkgs;
+  steamRuntime = stdenv.lib.optional (!nativeOnly) steam-runtime;
+
+in stdenv.mkDerivation rec {
+  name = "steam-runtime-wrapped";
+
+  allPkgs = ourRuntime ++ steamRuntime;
+
+  nativeBuildInputs = [ perl ];
+
+  builder = ./build-runtime.sh;
+
+  installPhase = ''
+    buildDir "${toString steam-runtime.libs}" "$allPkgs"
+    buildDir "${toString steam-runtime.bins}" "$allPkgs"
+  '';
+
+  meta.hydraPlatforms = [];
+}
diff --git a/pkgs/games/steam/steam.nix b/pkgs/games/steam/steam.nix
new file mode 100644
index 00000000000..2f2ce921176
--- /dev/null
+++ b/pkgs/games/steam/steam.nix
@@ -0,0 +1,38 @@
+{stdenv, fetchurl, traceDeps ? false}:
+
+stdenv.mkDerivation rec {
+  name = "${program}-original-${version}";
+  program = "steam";
+  version = "1.0.0.49";
+
+  src = fetchurl {
+    url = "http://repo.steampowered.com/steam/pool/steam/s/steam/${program}_${version}.tar.gz";
+    sha256 = "1c1gl5pwvb5gnnnqf5d9hpcjnfjjgmn4lgx8v0fbx1am5xf3p2gx";
+  };
+
+  traceLog = "/tmp/steam-trace-dependencies.log";
+
+  installPhase = ''
+    make DESTDIR=$out install
+    mv $out/usr/* $out #*/
+    rmdir $out/usr
+
+    rm $out/bin/steamdeps
+    ${stdenv.lib.optionalString traceDeps ''
+      cat > $out/bin/steamdeps <<EOF
+      #! /bin/bash
+      echo \$1 >> ${traceLog}
+      cat \$1 >> ${traceLog}
+      echo >> ${traceLog}
+      EOF
+      chmod +x $out/bin/steamdeps
+    ''}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A digital distribution platform";
+    homepage = http://store.steampowered.com/;
+    license = licenses.unfree;
+    maintainers = with maintainers; [ jagajaga ];
+  };
+}