nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 steam-run,
6 coreutils,
7 steamRoot ? "$HOME/.local/share/Steam",
8}:
9let
10 srcs =
11 let
12 url =
13 platform:
14 "https://web.archive.org/web/20240521141411/https://steamcdn-a.akamaihd.net/client/installer/steamcmd_${platform}.tar.gz";
15 in
16 {
17 x86_64-darwin = fetchurl {
18 url = url "osx";
19 hash = "sha256-jswXyJiOWsrcx45jHEhJD3YVDy36ps+Ne0tnsJe9dTs=";
20 };
21 x86_64-linux = fetchurl {
22 url = url "linux";
23 hash = "sha256-zr8ARr/QjPRdprwJSuR6o56/QVXl7eQTc7V5uPEHHnw=";
24 };
25 };
26in
27stdenv.mkDerivation {
28 pname = "steamcmd";
29 version = "20180104"; # According to steamcmd_linux.tar.gz mtime
30
31 src =
32 srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
33
34 # The source tarball does not have a single top-level directory.
35 preUnpack = ''
36 mkdir $name
37 cd $name
38 sourceRoot=.
39 '';
40
41 dontBuild = true;
42
43 installPhase = ''
44 mkdir -p $out/share/steamcmd
45 find . -type f -exec install -Dm 755 "{}" "$out/share/steamcmd/{}" \;
46
47 mkdir -p $out/bin
48 substitute ${./steamcmd.sh} $out/bin/steamcmd \
49 --subst-var out \
50 --subst-var-by coreutils ${coreutils} \
51 --subst-var-by steamRoot '${steamRoot}' \
52 --subst-var-by steamRun ${if stdenv.hostPlatform.isLinux then (lib.getExe steam-run) else "exec"}
53 chmod 0755 $out/bin/steamcmd
54 '';
55
56 meta = {
57 homepage = "https://developer.valvesoftware.com/wiki/SteamCMD";
58 description = "Steam command-line tools";
59 mainProgram = "steamcmd";
60 platforms = [
61 "x86_64-linux"
62 "x86_64-darwin"
63 ];
64 license = lib.licenses.unfreeRedistributable;
65 maintainers = with lib.maintainers; [ tadfisher ];
66 };
67}