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.12.0";
32
33 src = fetchFromGitHub {
34 owner = "lichess-org";
35 repo = "fishnet";
36 tag = "v${finalAttrs.version}";
37 hash = "sha256-35/izbCfDA5R+HudL8gdk7CVmwu+GLuVtwTuYAwSBDg=";
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-cBNooWIVRk3DsXuF03mSOPYrgadxg8gEhG2aReeUkGs=";
49
50 nativeInstallCheckInputs = [
51 versionCheckHook
52 ];
53 doInstallCheck = true;
54 versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
55
56 passthru = {
57 updateScript = lib.getExe (writeShellApplication {
58 name = "update-${finalAttrs.pname}";
59
60 runtimeInputs = [
61 curl
62 jq
63 nix-update
64 common-updater-scripts
65 ];
66
67 runtimeEnv = {
68 PNAME = finalAttrs.pname;
69 PKG_FILE = toString ./package.nix;
70 GITHUB_REPOSITORY = "${finalAttrs.src.owner}/${finalAttrs.src.repo}";
71 NNUE_BIG_FILE = nnueBigFile;
72 NNUE_BIG_HASH = nnueBigHash;
73 NNUE_SMALL_FILE = nnueSmallFile;
74 NNUE_SMALL_HASH = nnueSmallHash;
75 };
76
77 text = builtins.readFile ./update.bash;
78 });
79 };
80
81 meta = {
82 description = "Distributed Stockfish analysis for lichess.org";
83 homepage = "https://github.com/lichess-org/fishnet";
84 license = lib.licenses.gpl3Plus;
85 maintainers = with lib.maintainers; [
86 tu-maurice
87 thibaultd
88 ];
89 platforms = [
90 "aarch64-linux"
91 "x86_64-linux"
92 ];
93 mainProgram = "fishnet";
94 };
95})