mirror of
https://codeberg.org/spire/nix.git
synced 2026-08-02 12:25:00 +02:00
update scripts for depots
This commit is contained in:
parent
542e5196c6
commit
6bbab5abe1
9 changed files with 113 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
result
|
result
|
||||||
.direnv
|
.direnv
|
||||||
tmp
|
tmp
|
||||||
|
depots
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ sourcemod doesn't support all of them.
|
||||||
|
|
||||||
#### i686-linux
|
#### i686-linux
|
||||||
|
|
||||||
`episode1`, `orangebox`, `css`, `hl2dm`, `dods`, `sdk2013`, `tf2`, `l4d`, `l4d2`,
|
`episode1`, `orangebox`, `css`, `hl2dm`, `dods`, `sdk2013`, `tf2`, `l4d`,
|
||||||
`nucleardawn`, `csgo`, `insurgency`, `bms` and `doi`
|
`l4d2`, `nucleardawn`, `csgo`, `insurgency`, `bms` and `doi`
|
||||||
|
|
||||||
#### x86_64-linux
|
#### x86_64-linux
|
||||||
|
|
||||||
|
|
|
||||||
16
flake.nix
16
flake.nix
|
|
@ -43,7 +43,19 @@
|
||||||
metamods = pkgs.lib.mapAttrs (name: sdk: pkgs.metamod-source-builder {${name} = sdk;}) pkgs.hl2sdk;
|
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 = {
|
checks = {
|
||||||
buildTestScript = {pkgs, ...}:
|
buildTestScript = {pkgs, ...}:
|
||||||
|
|
@ -57,7 +69,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = {pkgs, ...}: {
|
devShells.default = {pkgs, ...}: {
|
||||||
packages = with pkgs; [nix-update];
|
packages = with pkgs; [nix-update depotdownloader];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
final: prev:
|
final: prev:
|
||||||
{
|
(import ./sourcemod/overlay.nix) final prev
|
||||||
srcds-tf2 = final.callPackage ./srcds {};
|
// (import ./srcds/overlay.nix) final prev
|
||||||
}
|
|
||||||
// (import ./sourcemod/overlay.nix) final prev
|
|
||||||
|
|
|
||||||
21
nix/srcds/depot.nix
Normal file
21
nix/srcds/depot.nix
Normal 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 [];
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"app_id": 232250,
|
"app_id": 232250,
|
||||||
"depot_id": 232256,
|
"depot_id": 232256,
|
||||||
"manifest": 698669566371320345,
|
"manifest": 698669566371320345,
|
||||||
"date": "2026-07-07T17:15:40Z",
|
"date": "2026-07-03T19:53:32+02:00",
|
||||||
"hash": "sha256-PNG0Xz08ozVjqYN2XZHr1/4TmrITIZA0kLax3LGMqZY="
|
"hash": "sha256-PNG0Xz08ozVjqYN2XZHr1/4TmrITIZA0kLax3LGMqZY="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
14
nix/srcds/overlay.nix
Normal file
14
nix/srcds/overlay.nix
Normal 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);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#! /usr/bin/env nu
|
#! /usr/bin/env nu
|
||||||
|
|
||||||
def main [] {
|
def main [] {
|
||||||
|
update_all_depots
|
||||||
|
|
||||||
nix-update --flake --use-update-script ambuild
|
nix-update --flake --use-update-script ambuild
|
||||||
nix build .#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-library
|
||||||
nix-update --flake --use-update-script sourcemod-include-steamworks
|
nix-update --flake --use-update-script sourcemod-include-steamworks
|
||||||
nix-update --flake --use-update-script sourcemod-includes
|
nix-update --flake --use-update-script sourcemod-includes
|
||||||
|
|
||||||
|
nix fmt
|
||||||
}
|
}
|
||||||
|
|
||||||
def update_sdk [sdk: string] {
|
def update_sdk [sdk: string] {
|
||||||
|
|
@ -36,3 +40,56 @@ def get_metamod_version [] {
|
||||||
let build = $html | query web --as-table [Build] | get Build | first
|
let build = $html | query web --as-table [Build] | get Build | first
|
||||||
$"($branch).0.($build)"
|
$"($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'
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue