diff --git a/pkgs/development/libraries/glew/1.10.nix b/pkgs/development/libraries/glew/1.10.nix new file mode 100644 index 000000000000..8f153baf6cd5 --- /dev/null +++ b/pkgs/development/libraries/glew/1.10.nix @@ -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; + }; +} diff --git a/pkgs/games/steam/build-runtime.sh b/pkgs/games/steam/build-runtime.sh new file mode 100644 index 000000000000..ddf974671a03 --- /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 ffd68562dee8..6028883c3633 100644 --- a/pkgs/games/steam/chrootenv.nix +++ b/pkgs/games/steam/chrootenv.nix @@ -1,79 +1,55 @@ -{ lib, buildFHSUserEnv, config }: +{ lib, buildFHSUserEnv +, withJava ? false +, withPrimus ? false +}: buildFHSUserEnv { name = "steam"; - targetPkgs = pkgs: - [ pkgs.steam-original - pkgs.corefonts - pkgs.curl - pkgs.dbus - pkgs.dpkg - pkgs.mono - pkgs.python - pkgs.gnome2.zenity - pkgs.xdg_utils - pkgs.xorg.xrandr - pkgs.which + targetPkgs = pkgs: with pkgs; [ + steamPackages.steam + steamPackages.steam-fonts + # Errors in output without those + pciutils + python2 + # Games' dependencies + xlibs.xrandr + which + # Needed by gdialog, including in the steam-runtime + perl ] - ++ lib.optional (config.steam.java or false) pkgs.jdk - ++ lib.optional (config.steam.primus or false) pkgs.primus + ++ lib.optional withJava jdk + ++ lib.optional withPrimus primus ; - multiPkgs = pkgs: - [ pkgs.cairo - pkgs.glib - pkgs.gtk - pkgs.gdk_pixbuf - pkgs.pango + multiPkgs = pkgs: with pkgs; [ + # These are required by steam with proper errors + xlibs.libXcomposite + xlibs.libXtst + xlibs.libXrandr + xlibs.libXext + xlibs.libX11 + xlibs.libXfixes - pkgs.freetype - pkgs.xorg.libICE - pkgs.xorg.libSM - pkgs.xorg.libX11 - 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 + # Not formally in runtime but needed by some games + gst_all_1.gstreamer + gst_all_1.gst-plugins-ugly + libdrm - pkgs.ffmpeg - 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 + steamPackages.steam-runtime-wrapped ]; - extraBuildCommandsMulti = '' - cd usr/lib - ln -sf ../lib64/steam steam + extraBuildCommands = '' + [ -d lib64 ] && mv lib64/steam lib + + mkdir -p steamrt + + ln -s ../lib64/steam-runtime steamrt/amd64 + ln -s ../lib/steam-runtime steamrt/i386 ''; profile = '' - # 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 + export STEAM_RUNTIME=/steamrt ''; runScript = "steam"; diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix index 2f2ce921176d..64f8cfe2c287 100644 --- a/pkgs/games/steam/default.nix +++ b/pkgs/games/steam/default.nix @@ -1,38 +1,14 @@ -{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 { }; + steam-fonts = callPackage ./fonts.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 <> ${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/fonts.nix b/pkgs/games/steam/fonts.nix new file mode 100644 index 000000000000..dab393a86fb3 --- /dev/null +++ b/pkgs/games/steam/fonts.nix @@ -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 + ''; +} diff --git a/pkgs/games/steam/runtime-wrapped.nix b/pkgs/games/steam/runtime-wrapped.nix new file mode 100644 index 000000000000..238626c4ab4c --- /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/runtime.nix b/pkgs/games/steam/runtime.nix new file mode 100644 index 000000000000..7e3e03b04e18 --- /dev/null +++ b/pkgs/games/steam/runtime.nix @@ -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 = []; + }; +} diff --git a/pkgs/games/steam/steam.nix b/pkgs/games/steam/steam.nix new file mode 100644 index 000000000000..2f2ce921176d --- /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 <> ${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 ]; + }; +} diff --git a/pkgs/os-specific/linux/udev/182.nix b/pkgs/os-specific/linux/udev/182.nix new file mode 100644 index 000000000000..fcf06e3e8990 --- /dev/null +++ b/pkgs/os-specific/linux/udev/182.nix @@ -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; + }; +} diff --git a/pkgs/tools/networking/network-manager/0.9.8.nix b/pkgs/tools/networking/network-manager/0.9.8.nix new file mode 100644 index 000000000000..fe19550bc67f --- /dev/null +++ b/pkgs/tools/networking/network-manager/0.9.8.nix @@ -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; + }; +} diff --git a/pkgs/tools/networking/network-manager/libnl-3.2.25.patch b/pkgs/tools/networking/network-manager/libnl-3.2.25.patch new file mode 100644 index 000000000000..17c2966b7064 --- /dev/null +++ b/pkgs/tools/networking/network-manager/libnl-3.2.25.patch @@ -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); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9ea857da8894..fc78dac5ee79 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2347,6 +2347,9 @@ let 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_openvpn = callPackage ../tools/networking/network-manager/openvpn.nix { }; @@ -6313,6 +6316,7 @@ let libgit2_0_21 = callPackage ../development/libraries/git2/0.21.nix { }; glew = callPackage ../development/libraries/glew { }; + glew110 = callPackage ../development/libraries/glew/1.10.nix { }; glfw = glfw3; glfw2 = callPackage ../development/libraries/glfw/2.x.nix { }; @@ -10320,6 +10324,9 @@ let udev = pkgs.systemd; 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 { }; udisks2 = callPackage ../os-specific/linux/udisks/2-default.nix { }; udisks = udisks1; @@ -13842,9 +13849,12 @@ let stardust = callPackage ../games/stardust {}; - steam-original = lowPrio (callPackage ../games/steam { }); - - steam = callPackage ../games/steam/chrootenv.nix { }; + steamPackages = callPackage ../games/steam { }; + steam = steamPackages.steam-chrootenv.override { + # DEPRECATED + withJava = config.steam.java or false; + withPrimus = config.steam.primus or false; + }; stuntrally = callPackage ../games/stuntrally { };