diff options
Diffstat (limited to 'srcds-pkgs/fetchdepotfile.nix')
-rw-r--r-- | srcds-pkgs/fetchdepotfile.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/srcds-pkgs/fetchdepotfile.nix b/srcds-pkgs/fetchdepotfile.nix new file mode 100644 index 0000000..6af2507 --- /dev/null +++ b/srcds-pkgs/fetchdepotfile.nix @@ -0,0 +1,46 @@ +# as nice as it would be to just put the file in its expected directory +# structure and symlinkJoin them together at the end, creating that structure +# sacrifices the use of steam's hashes -- nix hashing isn't hierarchical +# or anything, just "archive everything and hash it like another flat file". +{ lib, runCommand +, depotdownloader, cacert +}: +{ FileName, FileHash, Flags, cache, ... }: +with lib; +assert !hasPrefix "/" FileName; +let + dirname = dirOf FileName; + basename = baseNameOf FileName; + src = runCommand basename { + inherit (cache.passthru) app depot manifest; + inherit basename dirname FileName; + cache = "${cache}"; + + passthru = { inherit dirname basename; }; + nativeBuildInputs = [ depotdownloader cacert ]; + outputHashMode = "flat"; + outputHashAlgo = "sha1"; + outputHash = FileHash; + } '' + export HOME=$PWD + cp -r $cache/.DepotDownloader ./ + chmod -R 777 .DepotDownloader + DepotDownloader \ + -app $app -depot $depot -manifest $manifest \ + -filelist <(echo "$FileName") -dir . + + mv $FileName $out + chmod -x $out + ''; +# nix refuses to flat hash executables lol +in if bitAnd Flags 32 != 0 then + runCommand src.name { + inherit src; + inherit (src) passthru; + } '' + cp $src $out + chmod +x $out + '' +else src + + |