Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { stdenv
- , gcc8Stdenv
- , lib
- , libzip
- , boost
- , cmake
- , makeWrapper
- , fetchFromGitHub
- , linuxPackages ? null
- , cudnn ? null
- , cudatoolkit ? null
- , libGL_driver ? null
- , opencl-headers ? null
- , ocl-icd ? null
- , cudaSupport ? false}:
- assert !cudaSupport || (
- linuxPackages != null &&
- libGL_driver != null &&
- cudatoolkit != null &&
- cudnn != null);
- assert cudaSupport || (
- opencl-headers != null &&
- ocl-icd != null);
- let
- env = if cudaSupport
- then gcc8Stdenv
- else stdenv;
- in env.mkDerivation rec {
- pname = "katago";
- version = "1.3.3";
- src = fetchFromGitHub {
- owner = "lightvector";
- repo = "katago";
- rev = "v${version}";
- sha256 = "031pq0lhv2q46iip1d6nrhx5r669l3jc7gzdpw74j9xbhjvza9kz";
- };
- nativeBuildInputs = [
- cmake
- makeWrapper
- ];
- buildInputs = [
- libzip
- boost
- ] ++ lib.optionals cudaSupport [
- linuxPackages.nvidia_x11
- cudnn
- libGL_driver
- ] ++ lib.optionals (!cudaSupport) [
- opencl-headers
- ocl-icd
- ];
- cmakeFlags = [
- "-DNO_GIT_REVISION=ON"
- ] ++ lib.optionals cudaSupport [
- "-DUSE_BACKEND=CUDA"
- ] ++ lib.optionals (!cudaSupport) [
- "-DUSE_BACKEND=OPENCL"
- ];
- preConfigure = ''
- cd cpp/
- '' + lib.optionalString cudaSupport ''
- export CUDA_PATH="${cudatoolkit}"
- export EXTRA_LDFLAGS="-L${linuxPackages.nvidia_x11}/lib"
- '';
- installPhase = ''
- mkdir -p $out/bin; cp katago $out/bin;
- '';
- postInstall = lib.optionalString cudaSupport ''
- wrapProgram $out/bin/katago \
- --prefix LD_LIBRARY_PATH ":" "${linuxPackages.nvidia_x11}/lib"
- '';
- enableParallelBuilding = true;
- meta = with stdenv.lib; {
- description = "Go engine modeled after AlphaGo Zero";
- homepage = https://github.com/lightvector/katago;
- license = licenses.mit;
- maintainers = [ maintainers.omnipotententity ];
- platforms = platforms.linux;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment