Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchurl, fetchFromGitHub }: 2 3let 4 # The x86-64-modern may need to be refined further in the future 5 # but stdenv.hostPlatform CPU flags do not currently work on Darwin 6 # https://discourse.nixos.org/t/darwin-system-and-stdenv-hostplatform-features/9745 7 archDarwin = if stdenv.isx86_64 then "x86-64-modern" else "x86-64"; 8 arch = if stdenv.isDarwin then archDarwin else 9 if stdenv.isx86_64 then "x86-64" else 10 if stdenv.isi686 then "x86-32" else 11 if stdenv.isAarch64 then "armv8" else 12 "unknown"; 13 14 nnueFile = "nn-6877cd24400e.nnue"; 15 nnue = fetchurl { 16 name = nnueFile; 17 url = "https://tests.stockfishchess.org/api/nn/${nnueFile}"; 18 sha256 = "sha256-aHfNJEAOAbGf8SrjBoriQhUoAr3TMOZve2cDhlJR1uM="; 19 }; 20in 21 22stdenv.mkDerivation rec { 23 pname = "stockfish"; 24 version = "15"; 25 26 src = fetchFromGitHub { 27 owner = "official-stockfish"; 28 repo = "Stockfish"; 29 rev = "sf_${version}"; 30 sha256 = "sha256-sK4Jw9BPGRvlm9oIcgGcmHe8G4GR4cEuD8MtDrHZKew="; 31 }; 32 33 # This addresses a linker issue with Darwin 34 # https://github.com/NixOS/nixpkgs/issues/19098 35 preBuild = lib.optionalString stdenv.isDarwin '' 36 sed -i.orig '/^\#\#\# 3.*Link Time Optimization/,/^\#\#\# 3/d' Makefile 37 ''; 38 39 postUnpack = '' 40 sourceRoot+=/src 41 echo ${nnue} 42 cp "${nnue}" "$sourceRoot/${nnueFile}" 43 ''; 44 45 makeFlags = [ "PREFIX=$(out)" "ARCH=${arch}" "CXX=${stdenv.cc.targetPrefix}c++" ]; 46 buildFlags = [ "build" ]; 47 48 enableParallelBuilding = true; 49 50 meta = with lib; { 51 homepage = "https://stockfishchess.org/"; 52 description = "Strong open source chess engine"; 53 longDescription = '' 54 Stockfish is one of the strongest chess engines in the world. It is also 55 much stronger than the best human chess grandmasters. 56 ''; 57 maintainers = with maintainers; [ luispedro siraben ]; 58 platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux"]; 59 license = licenses.gpl3Only; 60 }; 61 62}