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,37 +20,12 @@
pkgsCross, pkgsCross,
requireFile, requireFile,
}: let }: 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; depotInputs = importJSON ./depots.json;
fetchSupported = elem system depotdownloader.meta.platforms;
fetcher = input: fetcher = input:
if fetchSupported callPackage ./depot.nix {
then
fetchSteam {
name = "steam-depot-${toString input.app_id}-${toString input.depot_id}";
appId = input.app_id; appId = input.app_id;
depotId = input.depot_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
'';
}; };
manifestUsed = manifest: any (depot: manifest.app_id == depot.app_id && manifest.depot_id == depot.depot_id) depots; manifestUsed = manifest: any (depot: manifest.app_id == depot.app_id && manifest.depot_id == depot.depot_id) depots;
usedManifests = filter manifestUsed depotInputs; usedManifests = filter manifestUsed depotInputs;

View file

@ -3,19 +3,39 @@
fetchSteam, fetchSteam,
appId, appId,
depotId, depotId,
hash ? null, system,
depotdownloader,
stdenvNoCC,
writeScript,
}: let }: let
inherit (lib) toString importJSON findFirst; inherit (lib) toString importJSON findFirst elem;
fetchSupported = elem system depotdownloader.meta.platforms;
depotInputs = importJSON ./depots.json; depotInputs = importJSON ./depots.json;
depotInput = findFirst (depot: depot.app_id == appId && depot.depot_id == depotId) {} depotInputs; depotInput = findFirst (depot: depot.app_id == appId && depot.depot_id == depotId) {} depotInputs;
in in
if fetchSupported
then
fetchSteam { fetchSteam {
name = "steam-depot-${toString appId}-${toString depotId}"; name = "steam-depot-${toString appId}-${toString depotId}";
inherit appId depotId; inherit appId depotId;
manifestId = depotInput.manifest; manifestId = depotInput.manifest;
hash = hash = depotInput.hash;
if (hash == null)
then depotInput.hash
else hash;
fileList = depotInput.file_list or []; 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
'';
}