update scripts for depots

This commit is contained in:
Robin Appelman 2026-07-09 00:17:59 +02:00
commit 6bbab5abe1
9 changed files with 113 additions and 10 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
result
.direnv
tmp
depots

View file

@ -57,8 +57,8 @@ sourcemod doesn't support all of them.
#### i686-linux
`episode1`, `orangebox`, `css`, `hl2dm`, `dods`, `sdk2013`, `tf2`, `l4d`, `l4d2`,
`nucleardawn`, `csgo`, `insurgency`, `bms` and `doi`
`episode1`, `orangebox`, `css`, `hl2dm`, `dods`, `sdk2013`, `tf2`, `l4d`,
`l4d2`, `nucleardawn`, `csgo`, `insurgency`, `bms` and `doi`
#### x86_64-linux

View file

@ -43,7 +43,19 @@
metamods = pkgs.lib.mapAttrs (name: sdk: pkgs.metamod-source-builder {${name} = sdk;}) pkgs.hl2sdk;
};
packages = inheritPkgs ["ambuild" "hl2sdk" "sourcepawn" "metamod-source" "sourcemod" "sourcemod-includes" "sourcemod-include-curl" "sourcemod-include-library" "sourcemod-include-steamworks" "srcds-tf2"];
packages = inheritPkgs [
"ambuild"
"hl2sdk"
"sourcepawn"
"metamod-source"
"sourcemod"
"sourcemod-includes"
"sourcemod-include-curl"
"sourcemod-include-library"
"sourcemod-include-steamworks"
"srcds-tf2"
"steam-depots"
];
checks = {
buildTestScript = {pkgs, ...}:
@ -57,7 +69,7 @@
};
devShells.default = {pkgs, ...}: {
packages = with pkgs; [nix-update];
packages = with pkgs; [nix-update depotdownloader];
};
};
}

View file

@ -1,5 +1,3 @@
final: prev:
{
srcds-tf2 = final.callPackage ./srcds {};
}
// (import ./sourcemod/overlay.nix) final prev
(import ./sourcemod/overlay.nix) final prev
// (import ./srcds/overlay.nix) final prev

21
nix/srcds/depot.nix Normal file
View file

@ -0,0 +1,21 @@
{
lib,
fetchSteam,
appId,
depotId,
hash ? null,
}: let
inherit (lib) toString importJSON findFirst;
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 [];
}

View file

@ -3,7 +3,7 @@
"app_id": 232250,
"depot_id": 232256,
"manifest": 698669566371320345,
"date": "2026-07-07T17:15:40Z",
"date": "2026-07-03T19:53:32+02:00",
"hash": "sha256-PNG0Xz08ozVjqYN2XZHr1/4TmrITIZA0kLax3LGMqZY="
},
{

14
nix/srcds/overlay.nix Normal file
View file

@ -0,0 +1,14 @@
final: prev: let
inherit (prev.lib) toString importJSON listToAttrs map;
depotInputs = importJSON ./depots.json;
in {
srcds-tf2 = final.callPackage ./default.nix {};
steam-depots = listToAttrs (map (depot: {
name = "steam-depot-${toString depot.app_id}-${toString depot.depot_id}";
value = final.callPackage ./depot.nix {
appId = depot.app_id;
depotId = depot.depot_id;
};
})
depotInputs);
}

View file

@ -1,6 +1,8 @@
#! /usr/bin/env nu
def main [] {
update_all_depots
nix-update --flake --use-update-script ambuild
nix build .#ambuild
@ -17,6 +19,8 @@ def main [] {
nix-update --flake --use-update-script sourcemod-include-library
nix-update --flake --use-update-script sourcemod-include-steamworks
nix-update --flake --use-update-script sourcemod-includes
nix fmt
}
def update_sdk [sdk: string] {
@ -36,3 +40,56 @@ def get_metamod_version [] {
let build = $html | query web --as-table [Build] | get Build | first
$"($branch).0.($build)"
}
def get_manifest [app: int, depot: int] {
let info = DepotDownloader -app $app -depot $depot -manifest-only | parse -r 'Manifest (?P<manifest>[0-9]+) \((?P<date>[^)]+)\)' | first
# builting rm doesn't work for some reason?
env rm -r ./depots
let manifest = $info | get manifest | into int
let date = $info | get date | into datetime | format date '%+'
{
app_id: $app,
depot_id: $depot,
manifest: $manifest,
date: $date,
}
}
def update_all_depots [] {
let $depots = open nix/srcds/depots.json
let updated = $depots | each {|manifest| update_manifest $manifest}
# save, so the nix build for determining the hashes sees the new manifest id
$updated | save -f nix/srcds/depots.json
let with_hashes = $updated | each {|manifest| update_manifest_hash $manifest}
$with_hashes | save -f nix/srcds/depots.json
}
def update_manifest [manifest: record] {
let new = get_manifest $manifest.app_id $manifest.depot_id
if ($new.manifest != $manifest.manifest) {
$manifest | merge $new | merge {hash: ""}
} else {
$manifest
}
}
def update_manifest_hash [manifest: record] {
if $manifest.hash == "" {
let new = get_manifest_hash $manifest
$manifest | merge {hash: $new}
} else {
$manifest
}
}
def get_manifest_hash [manifest: record] {
nix build $".#steam-depots.steam-depot-($manifest.app_id)-($manifest.depot_id)" | complete | get 'stderr' | extract_hash
}
def extract_hash [] {
parse -r "got: (?P<hash>sha256-[A-Za-z0-9+\/=]+)" | first | get 'hash'
}