Skip to content

Commit

Permalink
steam-run-native: init
Browse files Browse the repository at this point in the history
Refactor Steam so that native steam-run can be built as a free package and
expose it so that Hydra builds needed i686 packages.
  • Loading branch information
abbradar committed Oct 16, 2017
1 parent 12d6fed commit 38ffe0e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 31 deletions.
12 changes: 6 additions & 6 deletions 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
Expand Down Expand Up @@ -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}
''}
'';

Expand All @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions pkgs/games/steam/default.nix
Expand Up @@ -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;
};
};
Expand Down
20 changes: 15 additions & 5 deletions 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
}:
Expand Down Expand Up @@ -96,17 +96,27 @@ 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";

nativeBuildInputs = [ perl ];

builder = ./build-wrapped.sh;

passthru = {
inherit gnuArch libs bins;
arch = steamArch;
};

installPhase = ''
buildDir "${toString steam-runtime.libs}" "${toString (map lib.getLib allPkgs)}"
buildDir "${toString steam-runtime.bins}" "${toString (map lib.getBin allPkgs)}"
buildDir "${toString libs}" "${toString (map lib.getLib allPkgs)}"
buildDir "${toString bins}" "${toString (map lib.getBin allPkgs)}"
'';

meta.hydraPlatforms = [];
}
19 changes: 2 additions & 17 deletions 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);

Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -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;
Expand Down

0 comments on commit 38ffe0e

Please sign in to comment.