Subject: Re: [bug#49946] [PATCH v7 05/32] gnu: Add tree-sitter-cli.

From: "(" <[email-masked]>
Date: Fri, 25 Nov 2022 06:52:59 +0000

On Fri Nov 25, 2022 at 1:21 AM GMT, Pierre Langlois wrote:
> * gnu/packages/tree-sitter.scm (tree-sitter-cli): New variable.

> --- a/gnu/packages/tree-sitter.scm
> +++ b/gnu/packages/tree-sitter.scm

> @@ -76,3 +79,80 @@ (define-public tree-sitter
> +              (snippet
> +               '(begin

Please use a gexp here.

> +                  (with-output-to-file "lib/binding_rust/build.rs"
> +                    (lambda _
> +                      (format #t "fn main() {~@
> +                              println!(\"cargo:rustc-link-lib=tree-sitter\");~@
> +                              }~%")))
> +                  #t))))

The #T is redundant.

> +    (arguments
> +     `(;; Running test requires downloading fixtures, see the

Please use LIST.

> +       ;; script/fetch-fixtures script.
> +       #:tests? #f

Couldn't we fetch the fixtures ourselves with a secondary origin,
like I did here? <https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/golang.scm#n10561>

> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'delete-cargo.lock
> +           (lambda _ (delete-file "Cargo.lock")))
> +         (replace 'install
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (bin (string-append out "/bin"))
> +                    (lib (string-append out "/lib")))
> +               (mkdir-p bin)
> +               (install-file "target/release/tree-sitter" bin)))))))

Update this to modern Guix style, please:

  #~(modify-phases %standard-phases
      (add-after 'unpack 'delete-cargo-lock
        (lambda _
          (delete-file "Cargo.lock")))
      (replace 'install
        (lambda* (#:key outputs #:allow-other-keys)
          (let ((bin (string-append #$output "/bin")))
            (mkdir-p bin)
            (install-file "target/release/tree-sitter" bin)))))

    -- (