diff --git a/nix/srcds/default.nix b/nix/srcds/default.nix index 21e44fe..10ce7c4 100644 --- a/nix/srcds/default.nix +++ b/nix/srcds/default.nix @@ -20,38 +20,13 @@ pkgsCross, requireFile, }: let - inherit (lib) importJSON map toString elem last replaceStrings naturalSort filter any optionals optionalString; + inherit (lib) importJSON map last replaceStrings naturalSort filter any optionals optionalString; depotInputs = importJSON ./depots.json; - fetchSupported = elem system depotdownloader.meta.platforms; fetcher = input: - if fetchSupported - then - fetchSteam { - name = "steam-depot-${toString input.app_id}-${toString input.depot_id}"; - appId = input.app_id; - depotId = input.depot_id; - manifestId = input.manifest; - fileList = input.file_list or []; - hash = input.hash; - } - else - stdenvNoCC.mkDerivation { - name = "steam-depot-${toString input.app_id}-${toString input.depot_id}-depot"; - outputHashAlgo = "sha256"; - outputHashMode = "recursive"; - outputHash = input.hash; - builder = writeScript "restrict-message" '' - source ${stdenvNoCC}/setup - cat <<_EOF_ - - $out - fetchSteam is not supported on your platform. - You can build srcds for x86_64-linux first to fetch the depot. - - _EOF_ - exit 1 - ''; - }; + callPackage ./depot.nix { + appId = input.app_id; + depotId = input.depot_id; + }; manifestUsed = manifest: any (depot: manifest.app_id == depot.app_id && manifest.depot_id == depot.depot_id) depots; usedManifests = filter manifestUsed depotInputs; allDepots = map fetcher usedManifests; diff --git a/nix/srcds/depot.nix b/nix/srcds/depot.nix index 74a1fb6..2ebb473 100644 --- a/nix/srcds/depot.nix +++ b/nix/srcds/depot.nix @@ -3,19 +3,39 @@ fetchSteam, appId, depotId, - hash ? null, + system, + depotdownloader, + stdenvNoCC, + writeScript, }: let - inherit (lib) toString importJSON findFirst; + inherit (lib) toString importJSON findFirst elem; + fetchSupported = elem system depotdownloader.meta.platforms; depotInputs = importJSON ./depots.json; depotInput = findFirst (depot: depot.app_id == appId && depot.depot_id == depotId) {} depotInputs; in - fetchSteam { - name = "steam-depot-${toString appId}-${toString depotId}"; - inherit appId depotId; - manifestId = depotInput.manifest; - hash = - if (hash == null) - then depotInput.hash - else hash; - fileList = depotInput.file_list or []; - } + if fetchSupported + then + fetchSteam { + name = "steam-depot-${toString appId}-${toString depotId}"; + inherit appId depotId; + manifestId = depotInput.manifest; + hash = depotInput.hash; + fileList = depotInput.file_list or []; + } + else + stdenvNoCC.mkDerivation { + name = "steam-depot-${toString appId}-${toString depotId}-depot"; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = depotInput.hash; + builder = writeScript "restrict-message" '' + source ${stdenvNoCC}/setup + cat <<_EOF_ + + fetchSteam is not supported on your platform. + You can build for x86_64-linux first to fetch the depot. + + _EOF_ + exit 1 + ''; + }