Merge pull request #8299 from abbradar/steam-native

Steam: use native NixOS libraries instead of Steam Runtime
This commit is contained in:
Nikolay Amiantov 2015-10-20 17:07:29 +03:00
commit 1c48e74a33
12 changed files with 520 additions and 99 deletions

View File

@ -0,0 +1,52 @@
{ stdenv, fetchurl, mesa_glu, x11, libXmu, libXi }:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "glew-1.10.0";
src = fetchurl {
url = "mirror://sourceforge/glew/${name}.tgz";
sha256 = "01zki46dr5khzlyywr3cg615bcal32dazfazkf360s1znqh17i4r";
};
nativeBuildInputs = [ x11 libXmu libXi ];
propagatedNativeBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
patchPhase = ''
sed -i 's|lib64|lib|' config/Makefile.linux
${optionalString (stdenv ? cross) ''
sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
''}
'';
buildFlags = [ "all" ];
installFlags = [ "install.all" ];
preInstall = ''
export GLEW_DEST="$out"
'';
postInstall = ''
mkdir -pv $out/share/doc/glew
mkdir -p $out/lib/pkgconfig
cp glew*.pc $out/lib/pkgconfig
cp -r README.txt LICENSE.txt doc $out/share/doc/glew
'';
crossAttrs.makeFlags = [
"CC=${stdenv.cross.config}-gcc"
"LD=${stdenv.cross.config}-gcc"
"AR=${stdenv.cross.config}-ar"
"STRIP="
] ++ optional (stdenv.cross.libc == "msvcrt") "SYSTEM=mingw"
++ optional (stdenv.cross.libc == "libSystem") "SYSTEM=darwin";
meta = with stdenv.lib; {
description = "An OpenGL extension loading library for C(++)";
homepage = http://glew.sourceforge.net/;
license = licenses.free; # different files under different licenses
#["BSD" "GLX" "SGI-B" "GPL2"]
platforms = platforms.mesaPlatforms;
};
}

View File

@ -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"

View File

@ -1,79 +1,55 @@
{ lib, buildFHSUserEnv, config }: { lib, buildFHSUserEnv
, withJava ? false
, withPrimus ? false
}:
buildFHSUserEnv { buildFHSUserEnv {
name = "steam"; name = "steam";
targetPkgs = pkgs: targetPkgs = pkgs: with pkgs; [
[ pkgs.steam-original steamPackages.steam
pkgs.corefonts steamPackages.steam-fonts
pkgs.curl # Errors in output without those
pkgs.dbus pciutils
pkgs.dpkg python2
pkgs.mono # Games' dependencies
pkgs.python xlibs.xrandr
pkgs.gnome2.zenity which
pkgs.xdg_utils # Needed by gdialog, including in the steam-runtime
pkgs.xorg.xrandr perl
pkgs.which
] ]
++ lib.optional (config.steam.java or false) pkgs.jdk ++ lib.optional withJava jdk
++ lib.optional (config.steam.primus or false) pkgs.primus ++ lib.optional withPrimus primus
; ;
multiPkgs = pkgs: multiPkgs = pkgs: with pkgs; [
[ pkgs.cairo # These are required by steam with proper errors
pkgs.glib xlibs.libXcomposite
pkgs.gtk xlibs.libXtst
pkgs.gdk_pixbuf xlibs.libXrandr
pkgs.pango xlibs.libXext
xlibs.libX11
xlibs.libXfixes
pkgs.freetype # Not formally in runtime but needed by some games
pkgs.xorg.libICE gst_all_1.gstreamer
pkgs.xorg.libSM gst_all_1.gst-plugins-ugly
pkgs.xorg.libX11 libdrm
pkgs.xorg.libXau
pkgs.xorg.libxcb
pkgs.xorg.libXcursor
pkgs.xorg.libXdamage
pkgs.xorg.libXdmcp
pkgs.xorg.libXext
pkgs.xorg.libXfixes
pkgs.xorg.libXi
pkgs.xorg.libXinerama
pkgs.xorg.libXrandr
pkgs.xorg.libXrender
pkgs.xorg.libXScrnSaver
pkgs.xorg.libXtst
pkgs.xorg.libXxf86vm
pkgs.ffmpeg steamPackages.steam-runtime-wrapped
pkgs.libpng12
pkgs.mesa
pkgs.SDL
pkgs.SDL2
pkgs.libdrm
pkgs.libgcrypt
pkgs.zlib
pkgs.alsaLib
pkgs.libvorbis
pkgs.openal
pkgs.libpulseaudio
pkgs.gst_all_1.gst-plugins-ugly # "Audiosurf 2" needs this
]; ];
extraBuildCommandsMulti = '' extraBuildCommands = ''
cd usr/lib [ -d lib64 ] && mv lib64/steam lib
ln -sf ../lib64/steam steam
mkdir -p steamrt
ln -s ../lib64/steam-runtime steamrt/amd64
ln -s ../lib/steam-runtime steamrt/i386
''; '';
profile = '' profile = ''
# Ugly workaround for https://github.com/ValveSoftware/steam-for-linux/issues/3504 export STEAM_RUNTIME=/steamrt
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
''; '';
runScript = "steam"; runScript = "steam";

View File

@ -1,38 +1,14 @@
{stdenv, fetchurl, traceDeps ? false}: { pkgs, newScope }:
stdenv.mkDerivation rec { let
name = "${program}-original-${version}"; callPackage = newScope self;
program = "steam";
version = "1.0.0.49";
src = fetchurl { self = rec {
url = "http://repo.steampowered.com/steam/pool/steam/s/steam/${program}_${version}.tar.gz"; steam-runtime = callPackage ./runtime.nix { };
sha256 = "1c1gl5pwvb5gnnnqf5d9hpcjnfjjgmn4lgx8v0fbx1am5xf3p2gx"; steam-runtime-wrapped = callPackage ./runtime-wrapped.nix { };
steam = callPackage ./steam.nix { };
steam-chrootenv = callPackage ./chrootenv.nix { };
steam-fonts = callPackage ./fonts.nix { };
}; };
traceLog = "/tmp/steam-trace-dependencies.log"; in self
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 ];
};
}

View File

@ -0,0 +1,19 @@
{ stdenv, fetchurl, unzip }:
stdenv.mkDerivation {
name = "steam-fonts-1";
src = fetchurl {
url = https://support.steampowered.com/downloads/1974-YFKL-4947/SteamFonts.zip;
sha256 = "1cgygmwich5f1jhhbmbkkpnzasjl8gy36xln76n6r2gjh6awqfx0";
};
buildInputs = [ unzip ];
sourceRoot = ".";
installPhase = ''
mkdir -p $out/share/fonts/truetype
cp -r *.TTF *.ttf $out/share/fonts/truetype
'';
}

View File

@ -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 = [];
}

View File

@ -0,0 +1,41 @@
{ stdenv, fetchurl }:
let arch = if stdenv.system == "x86_64-linux" then "amd64"
else if stdenv.system == "i686-linux" then "i386"
else abort "Unsupported platform";
in stdenv.mkDerivation rec {
name = "steam-runtime-${version}";
version = "2014-04-15";
phases = [ "unpackPhase" "installPhase" ];
src = fetchurl {
url = "http://media.steampowered.com/client/runtime/steam-runtime-release_${version}.tar.xz";
sha256 = "0i6xp81rjbfn4664h4mmvw0xjwlwvdp6k7cc53jfjadcblw5cf99";
};
installPhase = ''
mkdir -p $out
mv ${arch}/* $out/
'';
passthru = rec {
inherit arch;
gnuArch = if arch == "amd64" then "x86_64-linux-gnu"
else if arch == "i386" then "i386-linux-gnu"
else abort "Unsupported architecture";
libs = [ "lib/${gnuArch}" "lib" "usr/lib/${gnuArch}" "usr/lib" ];
bins = [ "bin" "usr/bin" ];
};
meta = with stdenv.lib; {
description = "The official runtime used by Steam";
homepage = https://github.com/ValveSoftware/steam-runtime;
license = licenses.mit;
maintainers = with maintainers; [ hrdinka ];
hydraPlatforms = [];
};
}

View File

@ -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 ];
};
}

View File

@ -0,0 +1,34 @@
{ stdenv, fetchurl, pkgconfig
, pciutils, utillinux, kmod, usbutils, gperf
}:
assert stdenv ? glibc;
stdenv.mkDerivation rec {
name = "udev-182";
src = fetchurl {
url = "mirror://kernel/linux/utils/kernel/hotplug/${name}.tar.bz2";
sha256 = "143qvm0kij26j2l5icnch4x38fajys6li7j0c5mpwi6kqmc8hqx0";
};
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ utillinux kmod usbutils #glib gobjectIntrospection
gperf
];
configureFlags = [ "--with-pci-ids-path=${pciutils}/share/pci.ids"
"--disable-gudev"
"--disable-introspection"
];
NIX_LDFLAGS = [ "-lrt" ];
meta = with stdenv.lib; {
homepage = http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html;
description = "Udev manages the /dev filesystem";
platforms = platforms.linux;
license = licenses.gpl2;
};
}

View File

@ -0,0 +1,58 @@
{ stdenv, fetchurl, intltool, pkgconfig, dbus_glib
, udev, libnl, libuuid, gnutls, dhcp
, libgcrypt, perl }:
stdenv.mkDerivation rec {
name = "network-manager-${version}";
version = "0.9.8.10";
src = fetchurl {
url = "mirror://gnome/sources/NetworkManager/0.9/NetworkManager-${version}.tar.xz";
sha256 = "0wn9qh8r56r8l19dqr68pdl1rv3zg1dv47rfy6fqa91q7li2fk86";
};
preConfigure = ''
substituteInPlace tools/glib-mkenums --replace /usr/bin/perl ${perl}/bin/perl
'';
# Right now we hardcode quite a few paths at build time. Probably we should
# patch networkmanager to allow passing these path in config file. This will
# remove unneeded build-time dependencies.
configureFlags = [
"--with-distro=exherbo"
"--with-dhclient=${dhcp}/sbin/dhclient"
"--with-dhcpcd=no"
"--with-iptables=no"
"--with-udev-dir=\${out}/lib/udev"
"--with-resolvconf=no"
"--sysconfdir=/etc" "--localstatedir=/var"
"--with-dbus-sys-dir=\${out}/etc/dbus-1/system.d"
"--with-crypto=gnutls" "--disable-more-warnings"
"--with-systemdsystemunitdir=$(out)/etc/systemd/system"
"--with-kernel-firmware-dir=/run/current-system/firmware"
"--disable-ppp"
];
buildInputs = [ udev libnl libuuid gnutls libgcrypt ];
propagatedBuildInputs = [ dbus_glib ];
nativeBuildInputs = [ intltool pkgconfig ];
patches =
[ ./libnl-3.2.25.patch
./nixos-purity.patch
];
preInstall =
''
installFlagsArray=( "sysconfdir=$out/etc" "localstatedir=$out/var" )
'';
meta = with stdenv.lib; {
homepage = http://projects.gnome.org/NetworkManager/;
description = "Network configuration and management tool";
license = licenses.gpl2Plus;
platforms = platforms.linux;
};
}

View File

@ -0,0 +1,61 @@
diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c
index ba8053e..5ac39d3 100644
--- a/src/nm-netlink-monitor.c
+++ b/src/nm-netlink-monitor.c
@@ -177,40 +177,15 @@ link_msg_handler (struct nl_object *obj, void *arg)
static int
event_msg_recv (struct nl_msg *msg, void *arg)
{
- struct nl_sock *nlh = arg;
- struct nlmsghdr *hdr = nlmsg_hdr (msg);
struct ucred *creds = nlmsg_get_creds (msg);
- const struct sockaddr_nl *snl;
- guint32 local_port;
- gboolean accept_msg = FALSE;
-
- /* Only messages sent from the kernel */
- if (!creds || creds->uid != 0) {
- nm_log_dbg (LOGD_HW, "ignoring netlink message from UID %d",
- creds ? creds->uid : -1);
- return NL_SKIP;
- }
-
- snl = nlmsg_get_src (msg);
- g_assert (snl);
-
- /* Accept any messages from the kernel */
- if (hdr->nlmsg_pid == 0 || snl->nl_pid == 0)
- accept_msg = TRUE;
- /* And any multicast message directed to our netlink PID, since multicast
- * currently requires CAP_ADMIN to use.
- */
- local_port = nl_socket_get_local_port (nlh);
- if ((hdr->nlmsg_pid == local_port) && snl->nl_groups)
- accept_msg = TRUE;
-
- if (accept_msg == FALSE) {
- nm_log_dbg (LOGD_HW, "ignoring netlink message from PID %d (local PID %d, multicast %d)",
- hdr->nlmsg_pid,
- local_port,
- (hdr->nlmsg_flags & NLM_F_MULTI));
- return NL_SKIP;
+ if (!creds || creds->pid || creds->uid || creds->gid) {
+ if (creds)
+ nm_log_dbg (LOGD_HW, "netlink: received non-kernel message (pid %d uid %d gid %d)",
+ creds->pid, creds->uid, creds->gid);
+ else
+ nm_log_dbg (LOGD_HW, "netlink: received message without credentials");
+ return NL_STOP;
}
return NL_OK;
@@ -285,7 +260,7 @@ nlh_setup (struct nl_sock *nlh,
{
int err;
- nl_socket_modify_cb (nlh, NL_CB_MSG_IN, NL_CB_CUSTOM, event_msg_recv, cb_data);
+ nl_socket_modify_cb (nlh, NL_CB_MSG_IN, NL_CB_CUSTOM, event_msg_recv, NULL);
if (valid_func)
nl_socket_modify_cb (nlh, NL_CB_VALID, NL_CB_CUSTOM, valid_func, cb_data);

View File

@ -2347,6 +2347,9 @@ let
netselect = callPackage ../tools/networking/netselect { }; netselect = callPackage ../tools/networking/netselect { };
# stripped down, needed by steam
networkmanager098 = callPackage ../tools/networking/network-manager/0.9.8.nix { };
networkmanager = callPackage ../tools/networking/network-manager { }; networkmanager = callPackage ../tools/networking/network-manager { };
networkmanager_openvpn = callPackage ../tools/networking/network-manager/openvpn.nix { }; networkmanager_openvpn = callPackage ../tools/networking/network-manager/openvpn.nix { };
@ -6313,6 +6316,7 @@ let
libgit2_0_21 = callPackage ../development/libraries/git2/0.21.nix { }; libgit2_0_21 = callPackage ../development/libraries/git2/0.21.nix { };
glew = callPackage ../development/libraries/glew { }; glew = callPackage ../development/libraries/glew { };
glew110 = callPackage ../development/libraries/glew/1.10.nix { };
glfw = glfw3; glfw = glfw3;
glfw2 = callPackage ../development/libraries/glfw/2.x.nix { }; glfw2 = callPackage ../development/libraries/glfw/2.x.nix { };
@ -10320,6 +10324,9 @@ let
udev = pkgs.systemd; udev = pkgs.systemd;
eudev = callPackage ../os-specific/linux/eudev {}; eudev = callPackage ../os-specific/linux/eudev {};
# libudev.so.0
udev182 = callPackage ../os-specific/linux/udev/182.nix { };
udisks1 = callPackage ../os-specific/linux/udisks/1-default.nix { }; udisks1 = callPackage ../os-specific/linux/udisks/1-default.nix { };
udisks2 = callPackage ../os-specific/linux/udisks/2-default.nix { }; udisks2 = callPackage ../os-specific/linux/udisks/2-default.nix { };
udisks = udisks1; udisks = udisks1;
@ -13842,9 +13849,12 @@ let
stardust = callPackage ../games/stardust {}; stardust = callPackage ../games/stardust {};
steam-original = lowPrio (callPackage ../games/steam { }); steamPackages = callPackage ../games/steam { };
steam = steamPackages.steam-chrootenv.override {
steam = callPackage ../games/steam/chrootenv.nix { }; # DEPRECATED
withJava = config.steam.java or false;
withPrimus = config.steam.primus or false;
};
stuntrally = callPackage ../games/stuntrally { }; stuntrally = callPackage ../games/stuntrally { };