stockfish: 17 -> 17.1 by adding updateScript (#409849)

authored by Aleksana and committed by GitHub 476d33bb fa9f1ccb

+65 -7
+45 -7
pkgs/by-name/st/stockfish/package.nix
··· 3 3 stdenv, 4 4 fetchurl, 5 5 fetchFromGitHub, 6 - apple-sdk, 6 + versionCheckHook, 7 + _experimental-update-script-combinators, 8 + nix-update-script, 9 + writeShellApplication, 10 + nix, 11 + gnugrep, 7 12 }: 8 13 9 14 let ··· 24 29 "unknown"; 25 30 26 31 # These files can be found in src/evaluate.h 27 - nnueBigFile = "nn-1111cefa1111.nnue"; 32 + nnueBigFile = "nn-1c0000000000.nnue"; 33 + nnueBigHash = "sha256-HAAAAAAApn1imZnZMtDDc/dFDOQ80S0FYoaPTq+a4q0="; 28 34 nnueBig = fetchurl { 29 35 name = nnueBigFile; 30 36 url = "https://tests.stockfishchess.org/api/nn/${nnueBigFile}"; 31 - sha256 = "sha256-ERHO+hERa3cWG9SxTatMUPJuWSDHVvSGFZK+Pc1t4XQ="; 37 + hash = nnueBigHash; 32 38 }; 33 39 nnueSmallFile = "nn-37f18f62d772.nnue"; 40 + nnueSmallHash = "sha256-N/GPYtdy8xB+HWqso4mMEww8hvKrY+ZVX7vKIGNaiZ0="; 34 41 nnueSmall = fetchurl { 35 42 name = nnueSmallFile; 36 43 url = "https://tests.stockfishchess.org/api/nn/${nnueSmallFile}"; 37 - sha256 = "sha256-N/GPYtdy8xB+HWqso4mMEww8hvKrY+ZVX7vKIGNaiZ0="; 44 + hash = nnueSmallHash; 38 45 }; 39 46 in 40 47 41 48 stdenv.mkDerivation rec { 42 49 pname = "stockfish"; 43 - version = "17"; 50 + version = "17.1"; 44 51 45 52 src = fetchFromGitHub { 46 53 owner = "official-stockfish"; 47 54 repo = "Stockfish"; 48 - rev = "sf_${version}"; 49 - sha256 = "sha256-oXvLaC5TEUPlHjhm7tOxpNPY88QxYHFw+Cev3Q8NEeQ="; 55 + tag = "sf_${version}"; 56 + hash = "sha256-c8o1d7/yPnF3Eo7M/MSzYuYQr2qt2tIwyu7WfuKMAzg="; 50 57 }; 51 58 52 59 postUnpack = '' ··· 63 70 buildFlags = [ "build" ]; 64 71 65 72 enableParallelBuilding = true; 73 + 74 + nativeInstallCheckInputs = [ 75 + versionCheckHook 76 + ]; 77 + doInstallCheck = true; 78 + versionCheckProgram = "${placeholder "out"}/bin/stockfish"; 79 + versionCheckProgramArg = "--help"; 80 + 81 + passthru = { 82 + updateScript = _experimental-update-script-combinators.sequence [ 83 + (nix-update-script { 84 + extraArgs = [ "--version-regex=^sf_([\\d.]+)$" ]; 85 + }) 86 + (lib.getExe (writeShellApplication { 87 + name = "${pname}-nnue-updater"; 88 + runtimeInputs = [ 89 + nix 90 + gnugrep 91 + ]; 92 + runtimeEnv = { 93 + PNAME = pname; 94 + PKG_FILE = builtins.toString ./package.nix; 95 + NNUE_BIG_FILE = nnueBigFile; 96 + NNUE_BIG_HASH = nnueBigHash; 97 + NNUE_SMALL_FILE = nnueSmallFile; 98 + NNUE_SMALL_HASH = nnueSmallHash; 99 + }; 100 + text = builtins.readFile ./update.bash; 101 + })) 102 + ]; 103 + }; 66 104 67 105 meta = with lib; { 68 106 homepage = "https://stockfishchess.org/";
+20
pkgs/by-name/st/stockfish/update.bash
··· 1 + new_src="$(nix-build --attr "pkgs.$PNAME.src" --no-out-link)" 2 + new_nnue_big_file="$(grep --perl-regexp --only-matching 'EvalFileDefaultNameBig "\Knn-(\w+).nnue' "$new_src/src/evaluate.h")" 3 + new_nnue_small_file="$(grep --perl-regexp --only-matching 'EvalFileDefaultNameSmall "\Knn-(\w+).nnue' "$new_src/src/evaluate.h")" 4 + new_nnue_big_hash="$( 5 + nix hash convert --hash-algo sha256 "$( 6 + nix-prefetch-url --type sha256 "https://tests.stockfishchess.org/api/nn/$new_nnue_big_file" 7 + )" 8 + )" 9 + new_nnue_small_hash="$( 10 + nix hash convert --hash-algo sha256 "$( 11 + nix-prefetch-url --type sha256 "https://tests.stockfishchess.org/api/nn/$new_nnue_small_file" 12 + )" 13 + )" 14 + 15 + pkg_body="$(<"$PKG_FILE")" 16 + pkg_body="${pkg_body//"$NNUE_BIG_FILE"/"$new_nnue_big_file"}" 17 + pkg_body="${pkg_body//"$NNUE_BIG_HASH"/"$new_nnue_big_hash"}" 18 + pkg_body="${pkg_body//"$NNUE_SMALL_FILE"/"$new_nnue_small_file"}" 19 + pkg_body="${pkg_body//"$NNUE_SMALL_HASH"/"$new_nnue_small_hash"}" 20 + echo "$pkg_body" >"$PKG_FILE"