Subject: Re: [bug#63088] [PATCH v2] gnu: Add Lc0.

From: Liliana Marie Prikler <[email-masked]>
Date: Thu, 07 Sep 2023 19:03:57 +0200

Am Donnerstag, dem 07.09.2023 um 18:23 +0800 schrieb [email-masked]:
> From: zamfofex <[email-masked]>
> 
> * gnu/packages/games.scm (lc0): New variable.
Missing the entry for lc0-neural-network.
> 
> Signed-off-by: 宋文武 <[email-masked]>
> ---
>  gnu/packages/games.scm | 59
> ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
> index 760234b031..f82f1dcc52 100644
> --- a/gnu/packages/games.scm
> +++ b/gnu/packages/games.scm
> @@ -118,6 +118,7 @@ (define-module (gnu packages games)
>    #:use-module (gnu packages bash)
>    #:use-module (gnu packages bison)
>    #:use-module (gnu packages boost)
> +  #:use-module (gnu packages c)
>    #:use-module (gnu packages check)
>    #:use-module (gnu packages cmake)
>    #:use-module (gnu packages compression)
> @@ -171,6 +172,7 @@ (define-module (gnu packages games)
>    #:use-module (gnu packages linux)
>    #:use-module (gnu packages llvm)
>    #:use-module (gnu packages lua)
> +  #:use-module (gnu packages machine-learning)
>    #:use-module (gnu packages man)
>    #:use-module (gnu packages maths)
>    #:use-module (gnu packages messaging)
> @@ -10409,6 +10411,63 @@ (define-public stockfish
>        (home-page "https://stockfishchess.org/")
>        (license license:gpl3+))))
>  
> +(define lc0-neural-network
> +  (let ((hash
> +        
> "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
> +    (origin
> +      (method url-fetch)
> +      (uri (string-append
> "https://storage.lczero.org/files/networks/"
> +                          hash))
> +      (sha256
> +       (base32
> +        "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
> +      (file-name "lc0-neural-network"))))
> +
> +(define-public lc0
> +  (package
> +    (name "lc0")
> +    (version "0.30.0")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/LeelaChessZero/lc0")
> +             (commit (string-append "v" version))
> +             (recursive? #t)))
recursive? #t is meh ._.
Can we work around that?
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32
> "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
> +    (build-system meson-build-system)
> +    (native-search-paths
> +     (list (search-path-specification
> +            (variable "XDG_DATA_DIRS")
> +            (files '("share")))))
> +    (inputs
> +     `(("neural-network" ,lc0-neural-network)
> +       ("eigen" ,eigen)
> +       ("oneapi-dnnl" ,oneapi-dnnl)
> +       ("zlib" ,zlib)))
Use new-style inputs.
> +    (native-inputs
> +     (list googletest ispc pkg-config python))
> +    (arguments
> +     '(#:phases (modify-phases %standard-phases
> +                  (add-after 'install 'copy-net
> +                    (lambda* (#:key outputs inputs #:allow-other-
> keys)
> +                      (mkdir-p (string-append (assoc-ref outputs
> "out")
> +                                              "/share/lc0"))
> +                      (copy-file (assoc-ref inputs "neural-network")
> +                                 (string-append (assoc-ref outputs
> "out")
> +                                                "/share/lc0/neural-
> network")))))
Can we use search-input-file or the like here?
> +       #:configure-flags (list "-Ddnnl=true"
> +                               (string-append
> +                                "-Ddnnl_dir="
> +                                (assoc-ref %build-inputs "oneapi-
> dnnl")))))
> +    (synopsis "Chess engine using neural networks")
> +    (description "Lc0 is a UCI-compliant chess engine designed to
> play chess
> +via neural network, specifically those of the LeelaChessZero
> project.")
Is Lc0 = Leela Chess Zero?  What's the connection?
> +    (home-page "https://lczero.org")
> +    (license license:gpl3+)))
Cheers