diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix index e8a911bebd5e..5aab54b83221 100644 --- a/pkgs/games/steam/default.nix +++ b/pkgs/games/steam/default.nix @@ -19,6 +19,7 @@ let then pkgs.pkgsi686Linux.steamPackages.steam-runtime-wrapped else null; }; + steamcmd = callPackage ./steamcmd.nix { }; }; in self diff --git a/pkgs/games/steam/steamcmd.nix b/pkgs/games/steam/steamcmd.nix new file mode 100644 index 000000000000..6a2c7fe01b4f --- /dev/null +++ b/pkgs/games/steam/steamcmd.nix @@ -0,0 +1,46 @@ +{ stdenv, fetchurl, steam-run, bash +, steamRoot ? "~/.local/share/Steam" +}: + +stdenv.mkDerivation rec { + name = "steamcmd-${version}"; + version = "20180104"; # According to steamcmd_linux.tar.gz mtime + + src = fetchurl { + url = https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz; + sha256 = "0z0y0zqvhydmfc9y9vg5am0vz7m3gbj4l2dwlrfz936hpx301gyf"; + }; + + # The source tarball does not have a single top-level directory. + preUnpack = '' + mkdir $name + cd $name + sourceRoot=. + ''; + + buildInputs = [ bash steam-run ]; + + dontBuild = true; + + installPhase = '' + mkdir -p $out/share/steamcmd/linux32 + install -Dm755 steamcmd.sh $out/share/steamcmd/steamcmd.sh + install -Dm755 linux32/* $out/share/steamcmd/linux32 + + mkdir -p $out/bin + substitute ${./steamcmd.sh} $out/bin/steamcmd \ + --subst-var shell \ + --subst-var out \ + --subst-var-by steamRoot "${steamRoot}" \ + --subst-var-by steamRun ${steam-run} + chmod 0755 $out/bin/steamcmd + ''; + + meta = with stdenv.lib; { + description = "Steam command-line tools"; + homepage = "https://developer.valvesoftware.com/wiki/SteamCMD"; + platforms = platforms.linux; + license = licenses.unfreeRedistributable; + maintainers = with maintainers; [ tadfisher ]; + }; +} diff --git a/pkgs/games/steam/steamcmd.sh b/pkgs/games/steam/steamcmd.sh new file mode 100644 index 000000000000..e092a4fedbe9 --- /dev/null +++ b/pkgs/games/steam/steamcmd.sh @@ -0,0 +1,24 @@ +#!@bash@/bin/bash -e + +# Always run steamcmd in the user's Steam root. +STEAMROOT=@steamRoot@ + +# Create a facsimile Steam root if it doesn't exist. +if [ ! -e "$STEAMROOT" ]; then + mkdir -p "$STEAMROOT"/{appcache,config,logs,Steamapps/common} + mkdir -p ~/.steam + ln -sf "$STEAMROOT" ~/.steam/root + ln -sf "$STEAMROOT" ~/.steam/steam +fi + +# Copy the system steamcmd install to the Steam root. If we don't do +# this, steamcmd assumes the path to `steamcmd` is the Steam root. +# Note that symlinks don't work here. +if [ ! -e "$STEAMROOT/steamcmd.sh" ]; then + mkdir -p "$STEAMROOT/linux32" + # steamcmd.sh will replace these on first use + cp @out@/share/steamcmd/steamcmd.sh "$STEAMROOT/." + cp @out@/share/steamcmd/linux32/* "$STEAMROOT/linux32/." +fi + +@steamRun@/bin/steam-run "$STEAMROOT/steamcmd.sh" "$@" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7e0425b26b9d..b107fa5929a9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20218,6 +20218,8 @@ with pkgs; nativeOnly = true; }).run; + steamcmd = steamPackages.steamcmd; + linux-steam-integration = callPackage ../games/linux-steam-integration { gtk = pkgs.gtk3; };