summary refs log tree commit diff
path: root/pkgs/games/steam
diff options
context:
space:
mode:
authorTad Fisher <tadfisher@gmail.com>2018-04-12 15:32:14 -0700
committerTad Fisher <tadfisher@gmail.com>2018-09-08 13:39:32 -0700
commit0b2b7b2d537ddc988cae617e33918e1c73a23c13 (patch)
treea2875fcb395ec5d327b2c6c52d853e9f719f80bf /pkgs/games/steam
parentca2ba44cab47767c8127d1c8633e2b581644eb8f (diff)
downloadnixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.tar
nixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.tar.gz
nixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.tar.bz2
nixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.tar.lz
nixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.tar.xz
nixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.tar.zst
nixpkgs-0b2b7b2d537ddc988cae617e33918e1c73a23c13.zip
steamcmd: init at 20180104
Diffstat (limited to 'pkgs/games/steam')
-rw-r--r--pkgs/games/steam/default.nix1
-rw-r--r--pkgs/games/steam/steamcmd.nix46
-rw-r--r--pkgs/games/steam/steamcmd.sh24
3 files changed, 71 insertions, 0 deletions
diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix
index e8a911bebd5..5aab54b8322 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 00000000000..6a2c7fe01b4
--- /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 00000000000..e092a4fedbe
--- /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" "$@"