dedub depot logic

This commit is contained in:
Robin Appelman 2026-07-10 18:16:23 +02:00
commit b3c3245b4c
2 changed files with 37 additions and 42 deletions

View file

@ -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;

View file

@ -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
'';
}