diff --git a/pkgs/by-name/st/steamcmd/package.nix b/pkgs/by-name/st/steamcmd/package.nix index 25bcd8353f3d..2b64fbd0c596 100644 --- a/pkgs/by-name/st/steamcmd/package.nix +++ b/pkgs/by-name/st/steamcmd/package.nix @@ -3,19 +3,33 @@ stdenv, fetchurl, steam-run, - bash, coreutils, - steamRoot ? "~/.local/share/Steam", + steamRoot ? "$HOME/.local/share/Steam", }: - +let + srcs = + let + url = + platform: + "https://web.archive.org/web/20240521141411/https://steamcdn-a.akamaihd.net/client/installer/steamcmd_${platform}.tar.gz"; + in + { + x86_64-darwin = fetchurl { + url = url "osx"; + hash = "sha256-jswXyJiOWsrcx45jHEhJD3YVDy36ps+Ne0tnsJe9dTs="; + }; + x86_64-linux = fetchurl { + url = url "linux"; + hash = "sha256-zr8ARr/QjPRdprwJSuR6o56/QVXl7eQTc7V5uPEHHnw="; + }; + }; +in stdenv.mkDerivation { pname = "steamcmd"; version = "20180104"; # According to steamcmd_linux.tar.gz mtime - src = fetchurl { - url = "https://web.archive.org/web/20240521141411/https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz"; - hash = "sha256-zr8ARr/QjPRdprwJSuR6o56/QVXl7eQTc7V5uPEHHnw="; - }; + src = + srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); # The source tarball does not have a single top-level directory. preUnpack = '' @@ -24,24 +38,18 @@ stdenv.mkDerivation { 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/share/steamcmd + find . -type f -exec install -Dm 755 "{}" "$out/share/steamcmd/{}" \; mkdir -p $out/bin substitute ${./steamcmd.sh} $out/bin/steamcmd \ --subst-var out \ --subst-var-by coreutils ${coreutils} \ - --subst-var-by steamRoot "${steamRoot}" \ - --subst-var-by steamRun ${steam-run} + --subst-var-by steamRoot '${steamRoot}' \ + --subst-var-by steamRun ${if stdenv.hostPlatform.isLinux then (lib.getExe steam-run) else "exec"} chmod 0755 $out/bin/steamcmd ''; @@ -49,7 +57,10 @@ stdenv.mkDerivation { homepage = "https://developer.valvesoftware.com/wiki/SteamCMD"; description = "Steam command-line tools"; mainProgram = "steamcmd"; - platforms = lib.platforms.linux; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; license = lib.licenses.unfreeRedistributable; maintainers = with lib.maintainers; [ tadfisher ]; }; diff --git a/pkgs/by-name/st/steamcmd/steamcmd.sh b/pkgs/by-name/st/steamcmd/steamcmd.sh old mode 100644 new mode 100755 index 588badb41a1a..d689a152f3cd --- a/pkgs/by-name/st/steamcmd/steamcmd.sh +++ b/pkgs/by-name/st/steamcmd/steamcmd.sh @@ -20,8 +20,8 @@ fi 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/." + cd @out@/share/steamcmd + find . -type f -exec install -Dm 755 "{}" "$STEAMROOT/{}" \; fi -@steamRun@/bin/steam-run "$STEAMROOT/steamcmd.sh" "$@" +@steamRun@ "$STEAMROOT/steamcmd.sh" "$@"