aboutsummaryrefslogtreecommitdiff
path: root/srcds-pkgs/fetchdepotfile.nix
diff options
context:
space:
mode:
authoryuuko <yuuko@partyvan.io>2024-08-29 21:51:04 -0700
committeryuuko <yuuko@partyvan.io>2024-08-29 21:51:04 -0700
commit56449e59d7aabd1c06fb67a51a1e129b55cb9270 (patch)
tree19f3faf805e9b6461a5940d1a050d13e5271ef55 /srcds-pkgs/fetchdepotfile.nix
break out of system config
Diffstat (limited to 'srcds-pkgs/fetchdepotfile.nix')
-rw-r--r--srcds-pkgs/fetchdepotfile.nix46
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
+
+