nix/update-all.nu

38 lines
1.6 KiB
Nu
Executable file

#! /usr/bin/env nu
def main [] {
nix-update --flake --use-update-script ambuild
nix build .#ambuild
nix-update --flake --version=$"(get_metamod_version)" metamod-source
nix build .#metamods.x86_64-linux.tf2
nix-update --flake --use-update-script sourcemod
nix build .#sourcemods.x86_64-linux.tf2
let sdks = open nix/sourcemod/hl2sdks.json | columns
$sdks | each {|sdk| update_sdk $sdk}
nix-update --flake --use-update-script sourcemod-include-curl
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
}
def update_sdk [sdk: string] {
print $"Updating ($sdk) SDK"
# some sdks might have identical files at some point, so their hash can be the same
# nix-update will replace all occurences of the hash, which might not be correct
# so we put a unique dummy value in there to work around this
open nix/sourcemod/hl2sdks.json | update ([$sdk, "sha256"] | into cell-path) $"($sdk)-placeholder" | save -f nix/sourcemod/hl2sdks.json
nix-update --flake --use-update-script $"hl2sdk.($sdk)"
nix build .#sourcemods.x86_64-linux.tf2
}
def get_metamod_version [] {
let html = http get https://www.metamodsource.net/downloads.php/?branch=stable
let branch = $html | query web --query h3 | first | first | parse --regex "from (?P<branch>[0-9.]+) Branch" | get branch | first
let build = $html | query web --as-table [Build] | get Build | first
$"($branch).0.($build)"
}