summary refs log tree commit diff
path: root/pkgs/games/katago/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/games/katago/default.nix
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/games/katago/default.nix')
-rw-r--r--pkgs/games/katago/default.nix94
1 files changed, 55 insertions, 39 deletions
diff --git a/pkgs/games/katago/default.nix b/pkgs/games/katago/default.nix
index 492ccbb63ab..fb08ef44710 100644
--- a/pkgs/games/katago/default.nix
+++ b/pkgs/games/katago/default.nix
@@ -1,49 +1,50 @@
 { stdenv
 , gcc8Stdenv
-, lib
-, libzip
 , boost
 , cmake
-, makeWrapper
+, cudatoolkit
+, cudnn
+, eigen
 , fetchFromGitHub
-, fetchpatch
-, cudnn ? null
-, cudatoolkit ? null
-, libGL_driver ? null
-, opencl-headers ? null
-, ocl-icd ? null
-, gperftools ? null
-, cudaSupport ? false
-, useTcmalloc ? true}:
-
-assert cudaSupport -> (
-  libGL_driver != null &&
-  cudatoolkit != null &&
-  cudnn != null);
-
-assert !cudaSupport -> (
-  opencl-headers != null &&
-  ocl-icd != null);
+, gperftools
+, lib
+, libzip
+, makeWrapper
+, mesa
+, ocl-icd
+, opencl-headers
+, openssl
+, writeShellScriptBin
+, enableAVX2 ? stdenv.hostPlatform.avx2Support
+, enableBigBoards ? false
+, enableCuda ? false
+, enableContrib ? false
+, enableGPU ? true
+, enableTcmalloc ? true
+}:
 
-assert useTcmalloc -> (
-  gperftools != null);
+assert !enableGPU -> (
+  !enableCuda);
 
 let
-  env = if cudaSupport
+  env = if enableCuda
     then gcc8Stdenv
     else stdenv;
 
 in env.mkDerivation rec {
   pname = "katago";
-  version = "1.5.0";
+  version = "1.9.1";
+  githash = "c3220a5a404af835792c476f3f24904e4b799444";
 
   src = fetchFromGitHub {
     owner = "lightvector";
     repo = "katago";
-    rev = "${version}";
-    sha256 = "0ajdjdmlzwh7zwk5v0k9zzjawgkf7w30pzqp5bhcsdqz4svvyll2";
+    rev = "v${version}";
+    sha256 = "sha256-sAtPOqGe6fZ9mAtLdp80fTALXVkP9WdWQU2iTFGXe24=";
   };
 
+  fakegit = writeShellScriptBin "git" "echo ${githash}";
+
   nativeBuildInputs = [
     cmake
     makeWrapper
@@ -52,43 +53,58 @@ in env.mkDerivation rec {
   buildInputs = [
     libzip
     boost
-  ] ++ lib.optionals cudaSupport [
+  ] ++ lib.optionals (!enableGPU) [
+    eigen
+  ] ++ lib.optionals (enableGPU && enableCuda) [
     cudnn
-    libGL_driver
-  ] ++ lib.optionals (!cudaSupport) [
+    mesa.drivers
+  ] ++ lib.optionals (enableGPU && !enableCuda) [
     opencl-headers
     ocl-icd
-  ] ++ lib.optionals useTcmalloc [
+  ] ++ lib.optionals enableContrib [
+    openssl
+  ] ++ lib.optionals enableTcmalloc [
     gperftools
   ];
 
   cmakeFlags = [
     "-DNO_GIT_REVISION=ON"
-  ] ++ lib.optionals cudaSupport [
+  ] ++ lib.optionals (!enableGPU) [
+    "-DUSE_BACKEND=EIGEN"
+  ] ++ lib.optionals enableAVX2 [
+    "-DUSE_AVX2=ON"
+  ] ++ lib.optionals (enableGPU && enableCuda) [
     "-DUSE_BACKEND=CUDA"
-  ] ++ lib.optionals (!cudaSupport) [
+  ] ++ lib.optionals (enableGPU && !enableCuda) [
     "-DUSE_BACKEND=OPENCL"
-  ] ++ lib.optionals useTcmalloc [
+  ] ++ lib.optionals enableContrib [
+    "-DBUILD_DISTRIBUTED=1"
+    "-DNO_GIT_REVISION=OFF"
+    "-DGIT_EXECUTABLE=${fakegit}/bin/git"
+  ] ++ lib.optionals enableTcmalloc [
     "-DUSE_TCMALLOC=ON"
+  ] ++ lib.optionals enableBigBoards [
+    "-DUSE_BIGGER_BOARDS_EXPENSIVE=ON"
   ];
 
   preConfigure = ''
     cd cpp/
-  '' + lib.optionalString cudaSupport ''
+  '' + lib.optionalString enableCuda ''
     export CUDA_PATH="${cudatoolkit}"
     export EXTRA_LDFLAGS="-L/run/opengl-driver/lib"
   '';
 
   installPhase = ''
+    runHook preInstall
     mkdir -p $out/bin; cp katago $out/bin;
-  '' + lib.optionalString cudaSupport ''
+  '' + lib.optionalString enableCuda ''
     wrapProgram $out/bin/katago \
       --prefix LD_LIBRARY_PATH : "/run/opengl-driver/lib"
+  '' + ''
+    runHook postInstall
   '';
 
-  enableParallelBuilding = true;
-
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Go engine modeled after AlphaGo Zero";
     homepage    = "https://github.com/lightvector/katago";
     license     = licenses.mit;