From 38ffe0e1f6bcce05c7f209666354f3487b512149 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Mon, 16 Oct 2017 02:58:04 +0300 Subject: [PATCH] steam-run-native: init Refactor Steam so that native steam-run can be built as a free package and expose it so that Hydra builds needed i686 packages. --- pkgs/games/steam/chrootenv.nix | 12 ++++++------ pkgs/games/steam/default.nix | 10 +++++++--- pkgs/games/steam/runtime-wrapped.nix | 22 ++++++++++++++++------ pkgs/games/steam/runtime.nix | 19 ++----------------- pkgs/top-level/all-packages.nix | 3 +++ 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/pkgs/games/steam/chrootenv.nix b/pkgs/games/steam/chrootenv.nix index 0c59821bdd26..856e4f6c6c15 100644 --- a/pkgs/games/steam/chrootenv.nix +++ b/pkgs/games/steam/chrootenv.nix @@ -1,5 +1,5 @@ { stdenv, lib, writeScript, buildFHSUserEnv, steam -, steam-runtime, steam-runtime-i686 ? null +, steam-runtime-wrapped, steam-runtime-wrapped-i686 ? null , withJava ? false , withPrimus ? false , extraPkgs ? pkgs: [ ] # extra packages to add to targetPkgs @@ -69,9 +69,9 @@ in buildFHSUserEnv rec { extraBuildCommands = '' mkdir -p steamrt - ln -s ../lib/steam-runtime steamrt/${steam-runtime.arch} - ${lib.optionalString (steam-runtime-i686 != null) '' - ln -s ../lib32/steam-runtime steamrt/${steam-runtime-i686.arch} + ln -s ../lib/steam-runtime steamrt/${steam-runtime-wrapped.arch} + ${lib.optionalString (steam-runtime-wrapped-i686 != null) '' + ln -s ../lib32/steam-runtime steamrt/${steam-runtime-wrapped-i686.arch} ''} ''; @@ -96,8 +96,8 @@ in buildFHSUserEnv rec { inherit multiPkgs extraBuildCommands; runScript = - let ldPath = map (x: "/steamrt/${steam-runtime.arch}/" + x) steam-runtime.libs - ++ lib.optionals (steam-runtime-i686 != null) (map (x: "/steamrt/${steam-runtime-i686.arch}/" + x) steam-runtime-i686.libs); + let ldPath = map (x: "/steamrt/${steam-runtime-wrapped.arch}/" + x) steam-runtime-wrapped.libs + ++ lib.optionals (steam-runtime-wrapped-i686 != null) (map (x: "/steamrt/${steam-runtime-wrapped-i686.arch}/" + x) steam-runtime-wrapped-i686.libs); in writeScript "steam-run" '' #!${stdenv.shell} run="$1" diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix index ae3fe561272f..54805e91b2bd 100644 --- a/pkgs/games/steam/default.nix +++ b/pkgs/games/steam/default.nix @@ -4,14 +4,18 @@ let callPackage = newScope self; self = rec { + steamArch = if pkgs.stdenv.system == "x86_64-linux" then "amd64" + else if pkgs.stdenv.system == "i686-linux" then "i386" + else abort "Unsupported platform"; + steam-runtime = callPackage ./runtime.nix { }; steam-runtime-wrapped = callPackage ./runtime-wrapped.nix { }; steam = callPackage ./steam.nix { }; steam-fonts = callPackage ./fonts.nix { }; steam-chrootenv = callPackage ./chrootenv.nix { - steam-runtime-i686 = - if pkgs.system == "x86_64-linux" - then pkgs.pkgsi686Linux.steamPackages.steam-runtime + steam-runtime-wrapped-i686 = + if steamArch == "amd64" + then pkgs.pkgsi686Linux.steamPackages.steam-runtime-wrapped else null; }; }; diff --git a/pkgs/games/steam/runtime-wrapped.nix b/pkgs/games/steam/runtime-wrapped.nix index 3d614bda31e4..1ec9fc7d5d97 100644 --- a/pkgs/games/steam/runtime-wrapped.nix +++ b/pkgs/games/steam/runtime-wrapped.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, perl, pkgs, steam-runtime +{ stdenv, steamArch, lib, perl, pkgs, steam-runtime , nativeOnly ? false , runtimeOnly ? false }: @@ -96,6 +96,13 @@ let allPkgs = ourRuntime ++ steamRuntime; + gnuArch = if steamArch == "amd64" then "x86_64-linux-gnu" + else if steamArch == "i386" then "i386-linux-gnu" + else abort "Unsupported architecture"; + + libs = [ "lib/${gnuArch}" "lib" "usr/lib/${gnuArch}" "usr/lib" ]; + bins = [ "bin" "usr/bin" ]; + in stdenv.mkDerivation rec { name = "steam-runtime-wrapped"; @@ -103,10 +110,13 @@ in stdenv.mkDerivation rec { builder = ./build-wrapped.sh; - installPhase = '' - buildDir "${toString steam-runtime.libs}" "${toString (map lib.getLib allPkgs)}" - buildDir "${toString steam-runtime.bins}" "${toString (map lib.getBin allPkgs)}" - ''; + passthru = { + inherit gnuArch libs bins; + arch = steamArch; + }; - meta.hydraPlatforms = []; + installPhase = '' + buildDir "${toString libs}" "${toString (map lib.getLib allPkgs)}" + buildDir "${toString bins}" "${toString (map lib.getBin allPkgs)}" + ''; } diff --git a/pkgs/games/steam/runtime.nix b/pkgs/games/steam/runtime.nix index fa1da4791963..82fce93a66ae 100644 --- a/pkgs/games/steam/runtime.nix +++ b/pkgs/games/steam/runtime.nix @@ -1,10 +1,6 @@ -{ stdenv, fetchurl, writeText, python2, dpkg, binutils }: +{ stdenv, steamArch, fetchurl, writeText, python2, dpkg, binutils }: -let arch = if stdenv.system == "x86_64-linux" then "amd64" - else if stdenv.system == "i686-linux" then "i386" - else abort "Unsupported platform"; - - input = builtins.getAttr arch (import ./runtime-generated.nix { inherit fetchurl; }); +let input = builtins.getAttr steamArch (import ./runtime-generated.nix { inherit fetchurl; }); inputFile = writeText "steam-runtime.json" (builtins.toJSON input); @@ -18,17 +14,6 @@ in stdenv.mkDerivation { python2 ${./build-runtime.py} -i ${inputFile} -r $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; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d6394c53b6e4..5396e984b91c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17942,6 +17942,9 @@ with pkgs; }; steam-run = steam.run; + steam-run-native = (steam.override { + nativeOnly = true; + }).run; stepmania = callPackage ../games/stepmania { ffmpeg = ffmpeg_2;