nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 fetchurl,
6 versionCheckHook,
7 writeShellApplication,
8 curl,
9 jq,
10 nix-update,
11 common-updater-scripts,
12}:
13
14let
15 # These files can be found in Stockfish/src/evaluate.h
16 nnueBigFile = "nn-1c0000000000.nnue";
17 nnueBigHash = "sha256-HAAAAAAApn1imZnZMtDDc/dFDOQ80S0FYoaPTq+a4q0=";
18 nnueBig = fetchurl {
19 url = "https://tests.stockfishchess.org/api/nn/${nnueBigFile}";
20 hash = nnueBigHash;
21 };
22 nnueSmallFile = "nn-37f18f62d772.nnue";
23 nnueSmallHash = "sha256-N/GPYtdy8xB+HWqso4mMEww8hvKrY+ZVX7vKIGNaiZ0=";
24 nnueSmall = fetchurl {
25 url = "https://tests.stockfishchess.org/api/nn/${nnueSmallFile}";
26 hash = nnueSmallHash;
27 };
28in
29rustPlatform.buildRustPackage (finalAttrs: {
30 pname = "fishnet";
31 version = "2.9.5";
32
33 src = fetchFromGitHub {
34 owner = "lichess-org";
35 repo = "fishnet";
36 tag = "v${finalAttrs.version}";
37 hash = "sha256-+JkqxO7wwYZHwWRMboKGe8uo/F223efR+9pIsAIoFpU=";
38 fetchSubmodules = true;
39 };
40
41 postPatch = ''
42 cp -v '${nnueBig}' 'Stockfish/src/${nnueBigFile}'
43 cp -v '${nnueBig}' 'Fairy-Stockfish/src/${nnueBigFile}'
44 cp -v '${nnueSmall}' 'Stockfish/src/${nnueSmallFile}'
45 cp -v '${nnueSmall}' 'Fairy-Stockfish/src/${nnueSmallFile}'
46 '';
47
48 cargoHash = "sha256-WjBrv4GApT7LTnexLDhY7Zni5kLtvUzaGs2YuA3UiHE=";
49
50 nativeInstallCheckInputs = [
51 versionCheckHook
52 ];
53 doInstallCheck = true;
54 versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
55 versionCheckProgramArg = "--version";
56
57 passthru = {
58 updateScript = lib.getExe (writeShellApplication {
59 name = "update-${finalAttrs.pname}";
60
61 runtimeInputs = [
62 curl
63 jq
64 nix-update
65 common-updater-scripts
66 ];
67
68 runtimeEnv = {
69 PNAME = finalAttrs.pname;
70 PKG_FILE = builtins.toString ./package.nix;
71 GITHUB_REPOSITORY = "${finalAttrs.src.owner}/${finalAttrs.src.repo}";
72 NNUE_BIG_FILE = nnueBigFile;
73 NNUE_BIG_HASH = nnueBigHash;
74 NNUE_SMALL_FILE = nnueSmallFile;
75 NNUE_SMALL_HASH = nnueSmallHash;
76 };
77
78 text = builtins.readFile ./update.bash;
79 });
80 };
81
82 meta = with lib; {
83 description = "Distributed Stockfish analysis for lichess.org";
84 homepage = "https://github.com/lichess-org/fishnet";
85 license = licenses.gpl3Plus;
86 maintainers = with maintainers; [
87 tu-maurice
88 thibaultd
89 ];
90 platforms = [
91 "aarch64-linux"
92 "x86_64-linux"
93 ];
94 mainProgram = "fishnet";
95 };
96})