From c8615c5aab5e086d13b1c8cb8d3928adbece771f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 8 Jul 2026 22:44:32 +0200 Subject: [PATCH] update script for sourcemod --- nix/sourcemod/sourcemod.nix | 34 +++++++++++++++++++++++++++++----- update-all.nu | 6 ++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/nix/sourcemod/sourcemod.nix b/nix/sourcemod/sourcemod.nix index 371408d..e203181 100644 --- a/nix/sourcemod/sourcemod.nix +++ b/nix/sourcemod/sourcemod.nix @@ -7,6 +7,7 @@ lib, writeShellScriptBin, zlib, + writeScript, sdks ? {}, }: let inherit (builtins) concatStringsSep attrNames attrValues; @@ -28,11 +29,6 @@ in pname = "sourcemod"; version = "1.12.0.7239"; - NIX_CFLAGS_COMPILE = - "-Wno-error -Wno-error=format-truncation -Wno-error=ignored-attributes -Wno-error=reorder -Wno-error=sign-compare " - + "-Wno-error=stringop-truncation -Wno-error=dangling-pointer -Wno-error=template-id-cdtor -Wno-error=format-security " - + "-Wno-error=deprecated-declarations -Wno-error=stringop-overread"; - src = fetchFromGitHub { owner = "alliedmodders"; repo = finalAttrs.pname; @@ -41,6 +37,11 @@ in fetchSubmodules = true; }; + NIX_CFLAGS_COMPILE = + "-Wno-error -Wno-error=format-truncation -Wno-error=ignored-attributes -Wno-error=reorder -Wno-error=sign-compare " + + "-Wno-error=stringop-truncation -Wno-error=dangling-pointer -Wno-error=template-id-cdtor -Wno-error=format-security " + + "-Wno-error=deprecated-declarations -Wno-error=stringop-overread"; + nativeBuildInputs = [ ambuild @@ -66,4 +67,27 @@ in mkdir $out mv package $out/share ''; + + passthru.updateScript = writeScript "update-sourcemod" '' + #!/usr/bin/env nix-shell + #!nix-shell -i nu -p nurl common-updater-scripts + + let html = http get https://www.sourcemod.net/downloads.php?branch=stable + let branch = $html | query web --query h3 | first | first | parse --regex "from (?P[0-9.]+) Branch" | get branch | first + let build = $html | query web --as-table [Build] | get 1 | get Build | first + let newRev = $html | query web --query 'td a[href^="https://github.com/alliedmodders/sourcemod/tree/"]' --attribute ['href'] | first | get href | split words | last + + let oldHash = nix eval --raw .#sourcemod.src.hash + let oldRev = nix eval --raw .#sourcemod.src.rev + let oldVersion = nix eval --raw .#sourcemod.version + + let newHash = nurl https://github.com/alliedmodders/sourcemod $newRev --submodules --hash + let newVersion = $"($branch).0.($build)" + + let nix = open nix/sourcemod/sourcemod.nix | + str replace $oldHash $newHash | + str replace $oldVersion $newVersion | + str replace $oldRev $newRev + $nix | save -f nix/sourcemod/sourcemod.nix + ''; }) diff --git a/update-all.nu b/update-all.nu index 1edc513..6010f4e 100755 --- a/update-all.nu +++ b/update-all.nu @@ -3,8 +3,10 @@ def main [] { update_metamod - # let sdks = open nix/sourcemod/hl2sdks.json | columns - # $sdks | each {|sdk| update_sdk $sdk} + nix-update --flake --use-update-script sourcemod + + let sdks = open nix/sourcemod/hl2sdks.json | columns + $sdks | each {|sdk| update_sdk $sdk} } def update_sdk [sdk: string] {