Merge pull request #14413 from abbradar/steam-run

steam-run: add derivation
This commit is contained in:
Nikolay Amiantov 2016-04-04 18:04:45 +04:00
commit 88c97e2860
4 changed files with 69 additions and 35 deletions

View File

@ -1,5 +1,5 @@
{ runCommand, lib, writeText, writeScriptBin, stdenv, ruby } : { runCommand, lib, writeText, writeScriptBin, stdenv, ruby } :
{ env, runScript ? "bash", extraBindMounts ? [], extraInstallCommands ? "", importMeta ? {} } : { env, runScript ? "bash", extraBindMounts ? [], extraInstallCommands ? "", meta ? {}, passthru ? {} } :
let let
name = env.pname; name = env.pname;
@ -27,9 +27,9 @@ let
''; '';
in runCommand name { in runCommand name {
meta = importMeta; inherit meta;
passthru.env = passthru = passthru // {
runCommand "${name}-shell-env" { env = runCommand "${name}-shell-env" {
shellHook = '' shellHook = ''
export CHROOTENV_EXTRA_BINDS="${lib.concatStringsSep ":" extraBindMounts}:$CHROOTENV_EXTRA_BINDS" export CHROOTENV_EXTRA_BINDS="${lib.concatStringsSep ":" extraBindMounts}:$CHROOTENV_EXTRA_BINDS"
exec ${chroot-user}/bin/chroot-user ${env} bash -l ${init "bash"} "$(pwd)" exec ${chroot-user}/bin/chroot-user ${env} bash -l ${init "bash"} "$(pwd)"
@ -40,6 +40,7 @@ in runCommand name {
echo >&2 "" echo >&2 ""
exit 1 exit 1
''; '';
};
} '' } ''
mkdir -p $out/bin mkdir -p $out/bin
cat <<EOF >$out/bin/${name} cat <<EOF >$out/bin/${name}

View File

@ -1,4 +1,5 @@
{ lib, buildFHSUserEnv, steam { stdenv, lib, writeScript, buildFHSUserEnv, steam
, steam-runtime, steam-runtime-i686 ? null
, withJava ? false , withJava ? false
, withPrimus ? false , withPrimus ? false
, nativeOnly ? false , nativeOnly ? false
@ -6,7 +7,8 @@
, newStdcpp ? false , newStdcpp ? false
}: }:
buildFHSUserEnv { let
self = {
name = "steam"; name = "steam";
targetPkgs = pkgs: with pkgs; [ targetPkgs = pkgs: with pkgs; [
@ -22,13 +24,11 @@ buildFHSUserEnv {
which which
# Needed by gdialog, including in the steam-runtime # Needed by gdialog, including in the steam-runtime
perl perl
] ] ++ lib.optional withJava jdk
++ lib.optional withJava jdk
++ lib.optional withPrimus (primus.override { ++ lib.optional withPrimus (primus.override {
stdenv = overrideInStdenv stdenv [ useOldCXXAbi ]; stdenv = overrideInStdenv stdenv [ useOldCXXAbi ];
stdenv_i686 = overrideInStdenv pkgsi686Linux.stdenv [ useOldCXXAbi ]; stdenv_i686 = overrideInStdenv pkgsi686Linux.stdenv [ useOldCXXAbi ];
}) });
;
multiPkgs = pkgs: with pkgs; [ multiPkgs = pkgs: with pkgs; [
# These are required by steam with proper errors # These are required by steam with proper errors
@ -51,9 +51,10 @@ buildFHSUserEnv {
extraBuildCommands = '' extraBuildCommands = ''
mkdir -p steamrt mkdir -p steamrt
ln -s ../lib/steam-runtime steamrt/${steam-runtime.arch}
ln -s ../lib64/steam-runtime steamrt/amd64 ${lib.optionalString (steam-runtime-i686 != null) ''
ln -s ../lib32/steam-runtime steamrt/i386 ln -s ../lib32/steam-runtime steamrt/${steam-runtime-i686.arch}
''}
''; '';
extraInstallCommands = '' extraInstallCommands = ''
@ -68,4 +69,27 @@ buildFHSUserEnv {
''; '';
runScript = "steam"; runScript = "steam";
}
passthru.run = buildFHSUserEnv (self // {
name = "steam-run";
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);
in writeScript "steam-run" ''
#!${stdenv.shell}
run="$1"
if [ "$run" = "" ]; then
echo "Usage: steam-run command-to-run args..." >&2
exit 1
fi
shift
export LD_LIBRARY_PATH=${lib.concatStringsSep ":" ldPath}:$LD_LIBRARY_PATH
exec "$run" "$@"
'';
passthru = {};
});
};
in buildFHSUserEnv self

View File

@ -7,8 +7,13 @@ let
steam-runtime = callPackage ./runtime.nix { }; steam-runtime = callPackage ./runtime.nix { };
steam-runtime-wrapped = callPackage ./runtime-wrapped.nix { }; steam-runtime-wrapped = callPackage ./runtime-wrapped.nix { };
steam = callPackage ./steam.nix { }; steam = callPackage ./steam.nix { };
steam-chrootenv = callPackage ./chrootenv.nix { };
steam-fonts = callPackage ./fonts.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
else null;
};
}; };
in self in self

View File

@ -134,11 +134,12 @@ in
}; };
buildFHSUserEnv = args: userFHSEnv { buildFHSUserEnv = args: userFHSEnv {
env = buildFHSEnv (removeAttrs args [ "runScript" "extraBindMounts" "extraInstallCommands" "meta" ]); env = buildFHSEnv (removeAttrs args [ "runScript" "extraBindMounts" "extraInstallCommands" "meta" "passthru" ]);
runScript = args.runScript or "bash"; runScript = args.runScript or "bash";
extraBindMounts = args.extraBindMounts or []; extraBindMounts = args.extraBindMounts or [];
extraInstallCommands = args.extraInstallCommands or ""; extraInstallCommands = args.extraInstallCommands or "";
importMeta = args.meta or {}; meta = args.meta or {};
passthru = args.passthru or {};
}; };
buildMaven = callPackage ../build-support/build-maven.nix {}; buildMaven = callPackage ../build-support/build-maven.nix {};
@ -14901,12 +14902,15 @@ in
stockfish = callPackage ../games/stockfish { }; stockfish = callPackage ../games/stockfish { };
steamPackages = callPackage ../games/steam { }; steamPackages = callPackage ../games/steam { };
steam = steamPackages.steam-chrootenv.override { steam = steamPackages.steam-chrootenv.override {
# DEPRECATED # DEPRECATED
withJava = config.steam.java or false; withJava = config.steam.java or false;
withPrimus = config.steam.primus or false; withPrimus = config.steam.primus or false;
}; };
steam-run = steam.run;
stepmania = callPackage ../games/stepmania { }; stepmania = callPackage ../games/stepmania { };
stuntrally = callPackage ../games/stuntrally { }; stuntrally = callPackage ../games/stuntrally { };