[PATCH 00/31] Tree-sitter, node-gyp addon support and emacs-tree-sitter

  • Open
  • quality assurance status badge
Details
9 participants
  • Andrew Tropin
  • Liliana Marie Prikler
  • Luis Henrique Gomes Higino
  • Maxime Devos
  • Mekeor Melire
  • (
  • Philip McGrath
  • Pierre Langlois
  • zimoun
Owner
unassigned
Submitted by
Pierre Langlois
Severity
normal
P
P
Pierre Langlois wrote on 9 Aug 2021 00:29
(address . guix-patches@gnu.org)
87h7fztt60.fsf@gmx.com
Hi Guix!

Here's a patch series that adds support for the Tree-sitter library,
command-line tool and its support in emacs:

The series in split into multiple parts:

1. Add the tree-sitter package, which is both a command-line tool for
generating parsers and a runtime library. The runtime is written in
C but the tooling in Rust.

* gnu: rust-chunked-transfer: Update to 1.4.0.
* gnu: Add rust-fdlimit.
* gnu: Add rust-html-escape.
* gnu: Add rust-smallbitvec.
* gnu: rust-tiny-http: Update to 0.8.
* gnu: rust-spin: Update to 0.7.
* gnu: Add tree-sitter.

2. Add support for native addons to the node build-system.

* gnu: node: Patch /usr/bin/env in node-gyp.
* guix: node-build-system: Support compiling addons with node-gyp.

I've not touched the node build system before so it'd be great to get
some review here!

The idea is that when a package has a `binding.gyp' file then there's
native code that needs to be compiled against node. This uses
node-gyp, which is a build system written in python.
Normally, there shouldn't be anything to do, the package.json file
should invoke `node-gyp` tp compile C code. However, `node-gyp' needs
node headers to compile against, packaged as a tarball, which it tries
to download. Instead, we can run a `node-gyp --tarball <> configure'
step to manually provide the tarball, which we can package separately
for any given node version.

I could have added this into the packages themselves, but I thought it
made more sense to be a part of the build system, let me know what you
think!

3. Packaging grammars for multiple languages.

Tree-sitter grammars are Nodejs packages, they consist of a grammar.js
file which the tree-sitter command-line program uses to generate C
code for the parser/scanner. Using npm as a packaging mechanism for
this seems overkill, but it's true some grammars depend on each other
(cpp on c, typescript and javascript).

* gnu: Add node-nan.
* gnu: Add tree-sitter-c.
* gnu: Add tree-sitter-cpp.
* gnu: Add tree-sitter-css.
* gnu: Add tree-sitter-go.
* gnu: Add tree-sitter-html.
* gnu: Add tree-sitter-java.
* gnu: Add tree-sitter-javascript.
* gnu: Add tree-sitter-json.
* gnu: Add tree-sitter-julia.
* gnu: Add tree-sitter-php.
* gnu: Add tree-sitter-python.
* gnu: Add tree-sitter-rust.
* gnu: Add tree-sitter-typescript.

4. Finally, emacs support!

emacs-tree-sitter can be used for syntax highlighting, replacing
font-lock. The tree-sitter runtime library is built as a Rust crate
and exposed to emacs using a module thanks to the rust-emacs crate.

Then emacs-tree-sitter-core provides just the core APIs as exposed by
the rust module, then emacs-tree-sitter integrates it with emacs'
syntax highlighting (and probably other things).

Finally, we bundle together the various language grammars into a
single emacs-tree-sitter-langs package so that they can get loaded
along with their respective major modes. Note that there are grammars
left to support which I've not yet managed to package, but what we
have already is a good start I think :-). So far I've tested C++,
Rust, Python and JavaScript and JSON.

* gnu: Add rust-bindgen@0.56.
* gnu: Add rust-tree-sitter.
* gnu: rust-emacs-module: Update to 0.16.
* gnu: rust-emacs-macros: Update to 0.17.
* gnu: rust-emacs: Update to 0.17.
* gnu: Add emacs-tree-sitter-core.
* gnu: Add emacs-tree-sitter.
* gnu: Add emacs-tree-sitter-langs.


Let me know what you think! This rebuilds all node packages, but there
aren't that many so hopefully that'll be ok on master.

Thanks,
Pierre

Pierre Langlois (31):
gnu: rust-chunked-transfer: Update to 1.4.0.
gnu: Add rust-fdlimit.
gnu: Add rust-html-escape.
gnu: Add rust-smallbitvec.
gnu: rust-tiny-http: Update to 0.8.
gnu: rust-spin: Update to 0.7.
gnu: Add tree-sitter.
gnu: node: Patch /usr/bin/env in node-gyp.
guix: node-build-system: Support compiling addons with node-gyp.
gnu: Add node-nan.
gnu: Add tree-sitter-c.
gnu: Add tree-sitter-cpp.
gnu: Add tree-sitter-css.
gnu: Add tree-sitter-go.
gnu: Add tree-sitter-html.
gnu: Add tree-sitter-java.
gnu: Add tree-sitter-javascript.
gnu: Add tree-sitter-json.
gnu: Add tree-sitter-julia.
gnu: Add tree-sitter-php.
gnu: Add tree-sitter-python.
gnu: Add tree-sitter-rust.
gnu: Add tree-sitter-typescript.
gnu: Add rust-bindgen@0.56.
gnu: Add rust-tree-sitter.
gnu: rust-emacs-module: Update to 0.16.
gnu: rust-emacs-macros: Update to 0.17.
gnu: rust-emacs: Update to 0.17.
gnu: Add emacs-tree-sitter-core.
gnu: Add emacs-tree-sitter.
gnu: Add emacs-tree-sitter-langs.

gnu/local.mk | 1 +
gnu/packages/crates-io.scm | 290 +++++++++++--
gnu/packages/node-xyz.scm | 30 ++
gnu/packages/node.scm | 29 +-
gnu/packages/tree-sitter.scm | 716 +++++++++++++++++++++++++++++++
guix/build-system/node.scm | 16 +
guix/build/node-build-system.scm | 15 +
7 files changed, 1064 insertions(+), 33 deletions(-)
create mode 100644 gnu/packages/tree-sitter.scm

--
2.32.0
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmEQaBcYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31Uk64H/RTjvpOAq1dLgQVt69syGPZO
cx2KRhhKea+vAnjzkcau71H+ekqv2faeUCeRYJATBViOsavxbs0cMp4lqTS+7YQY
1K0rH/sR0Kc4D5Reb6OhUBkp1QjbrETydrAhp9vdX8KPwsMf8qApaxZT7KC49eYj
UeiCFytDQ0f7fcELUWMnIsy3ca1F9Q/FarUofITWGNiJ5biWxkr0xhdO4qe7roo/
xEElSYGbVp7qNeXcyku7kRWQES7F2ijsc354Hv1G6HAA76tkyDF6r2OOzKtGLFPg
rpfduwfzWo4DENtOvSjekIHtkVSWuW3g5s6ThN+jSoAZf0IUE4XoxSn5i5b/Keg=
=vVea
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 02/31] gnu: Add rust-fdlimit.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-2-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-fdlimit-0.1): New variable.
---
gnu/packages/crates-io.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (33 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 01a0dff724..d6b52a217f 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -15930,6 +15930,28 @@ floats.")
it.")
(license (list license:expat license:asl2.0))))

+(define-public rust-fdlimit-0.1
+ (package
+ (name "rust-fdlimit")
+ (version "0.1.4")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "fdlimit" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0g30d6gqkrwy8ylwdy7pqm443iq0p5dmnpz4ks41pirl7dclm98d"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-libc" ,rust-libc-0.2))))
+ (home-page "https://github.com/paritytech/fdlimit")
+ (synopsis "Raise the open file descriptors limit")
+ (description "Utility crate for raising file descriptors limit.")
+ (license license:asl2.0)))
+
(define-public rust-femme-2
(package
(name "rust-femme")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 03/31] gnu: Add rust-html-escape.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-3-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-html-escape-0.2): New variable.
---
gnu/packages/crates-io.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index d6b52a217f..4a9db4943b 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -20824,6 +20824,32 @@ Hash-based Message Authentication Code algorithm} for SHA1.")
"This package provides a library for HTML entity encoding and decoding.")
(license (list license:asl2.0 license:expat license:mpl2.0))))

+(define-public rust-html-escape-0.2
+ (package
+ (name "rust-html-escape")
+ (version "0.2.9")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "html-escape" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1dxw9lpckrqzzqgbkw64ckbajr4b7xxnjdn8adgzqf2mm40shvl1"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-utf8-width" ,rust-utf8-width-0.1))
+ #:cargo-development-inputs
+ (("rust-bencher" ,rust-bencher-0.1))))
+ (home-page "https://magiclen.org/html-escape")
+ (synopsis "Library for encoding and escaping special characters in HTML")
+ (description
+ "This package provides a library for encoding and escaping special
+characters in HTML, decoding and unescaping HTML entities as well.")
+ (license license:expat)))
+
(define-public rust-http-0.2
(package
(name "rust-http")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 01/31] gnu: rust-chunked-transfer: Update to 1.4.0.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-1-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-chunked-transfer-1): New variable.
(rust-chunked-transfer-0.3): Inherit from rust-chunked-transfer-1.
---
gnu/packages/crates-io.scm | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

Toggle diff (58 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 24cc772ba7..01a0dff724 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -18,6 +18,7 @@
;;; Copyright © 2021 Antero Mejr <antero@kodmin.com>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -7825,19 +7826,21 @@ Python arrow.humanize.")
TimeZone trait for @code{rust-chrono}.")
(license (list license:expat license:asl2.0))))

-(define-public rust-chunked-transfer-0.3
+(define-public rust-chunked-transfer-1
(package
(name "rust-chunked-transfer")
- (version "0.3.1")
+ (version "1.4.0")
(source
(origin
(method url-fetch)
(uri (crate-uri "chunked_transfer" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
- (base32 "11yghnd24w0i9p8g368c3pg7qh9nfz7kgri6pywja9pnmakj13a9"))))
+ (base32 "0bkdlsrszfcscw3j6yhs7kj6jbp8id47jjk6h9k58px47na5gy7z"))))
(build-system cargo-build-system)
- (arguments `(#:skip-build? #t))
+ (arguments
+ `(#:cargo-development-inputs
+ (("rust-criterion" ,rust-criterion-0.3))))
(home-page "https://github.com/frewsxcv/rust-chunked-transfer")
(synopsis "Encoder and decoder for HTTP chunked transfer coding")
(description
@@ -7845,6 +7848,19 @@ TimeZone trait for @code{rust-chrono}.")
coding.")
(license license:asl2.0)))

+(define-public rust-chunked-transfer-0.3
+ (package (inherit rust-chunked-transfer-1)
+ (name "rust-chunked-transfer")
+ (version "0.3.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "chunked_transfer" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "11yghnd24w0i9p8g368c3pg7qh9nfz7kgri6pywja9pnmakj13a9"))))
+ (arguments `(#:skip-build? #t))))
+
(define-public rust-ci-info-0.3
(package
(name "rust-ci-info")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 05/31] gnu: rust-tiny-http: Update to 0.8.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-5-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-tiny-http-0.8): New variable.
(rust-tiny-http-0.6): Inherit from rust-tiny-http-0.8.
---
gnu/packages/crates-io.scm | 39 ++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)

Toggle diff (58 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 2274e4f12b..bb31356ceb 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -48810,8 +48810,39 @@ closures after a delay or at a given timestamp.")
manipulation in Rust.")
(license license:expat)))

-(define-public rust-tiny-http-0.6
+(define-public rust-tiny-http-0.8
(package
+ (name "rust-tiny-http")
+ (version "0.8.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "tiny_http" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0fcdwpb2ghk671qjjrk6048hs3yp7f681hxpr68gamk00181prcw"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-ascii" ,rust-ascii-1)
+ ("rust-chrono" ,rust-chrono-0.4)
+ ("rust-chunked-transfer" ,rust-chunked-transfer-1)
+ ("rust-log" ,rust-log-0.4)
+ ("rust-openssl" ,rust-openssl-0.10)
+ ("rust-url" ,rust-url-2))
+ #:cargo-development-inputs
+ (("rust-fdlimit" ,rust-fdlimit-0.1)
+ ("rust-rustc-serialize" ,rust-rustc-serialize-0.3)
+ ("rust-sha1" ,rust-sha1-0.6))))
+ (home-page "https://github.com/tiny-http/tiny-http")
+ (synopsis "Low level HTTP server library")
+ (description "This package provides a low level HTTP server library.")
+ (license license:asl2.0)))
+
+(define-public rust-tiny-http-0.6
+ (package (inherit rust-tiny-http-0.8)
(name "rust-tiny-http")
(version "0.6.2")
(source
@@ -48830,11 +48861,7 @@ manipulation in Rust.")
("rust-chunked-transfer" ,rust-chunked-transfer-0.3)
("rust-log" ,rust-log-0.4)
("rust-openssl" ,rust-openssl-0.10)
- ("rust-url" ,rust-url-1))))
- (home-page "https://github.com/tiny-http/tiny-http")
- (synopsis "Low level HTTP server library")
- (description "This package provides a low level HTTP server library.")
- (license license:asl2.0)))
+ ("rust-url" ,rust-url-1))))))

(define-public rust-tiny-keccak-2
(package
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 06/31] gnu: rust-spin: Update to 0.7.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-6-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-spin-0.7): New variable.
(rust-spin-0.5): Inherit from rust-spin-0.7.
---
gnu/packages/crates-io.scm | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

Toggle diff (52 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index bb31356ceb..b551e6921d 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -44496,10 +44496,10 @@ track of where each new file and line starts.")
"An RSpec inspired minimal testing framework for Rust.")
(license license:expat)))

-(define-public rust-spin-0.5
+(define-public rust-spin-0.7
(package
(name "rust-spin")
- (version "0.5.2")
+ (version "0.7.1")
(source
(origin
(method url-fetch)
@@ -44507,8 +44507,11 @@ track of where each new file and line starts.")
(file-name (string-append name "-" version ".crate"))
(sha256
(base32
- "0b84m6dbzrwf2kxylnw82d3dr8w06av7rfkr8s85fb5f43rwyqvf"))))
+ "0qjips9f6fsvkyd7wj3a4gzaqknn2q4kkb19957pl86im56pna0k"))))
(build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-lock-api" ,rust-lock-api-0.4))))
(home-page "https://github.com/mvdnes/spin-rs")
(synopsis "Synchronization primitives based on spinning")
(description "This crate provides synchronization primitives based on
@@ -44516,6 +44519,21 @@ spinning. They may contain data, are usable without @code{std},and static
initializers are available.")
(license license:expat)))

+(define-public rust-spin-0.5
+ (package
+ (inherit rust-spin-0.7)
+ (name "rust-spin")
+ (version "0.5.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "spin" version))
+ (file-name (string-append name "-" version ".crate"))
+ (sha256
+ (base32
+ "0b84m6dbzrwf2kxylnw82d3dr8w06av7rfkr8s85fb5f43rwyqvf"))))
+ (arguments '(#:cargo-inputs ()))))
+
(define-public rust-spin-0.4
(package
(inherit rust-spin-0.5)
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 04/31] gnu: Add rust-smallbitvec.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-4-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-smallbitvec-2): New variable.
---
gnu/packages/crates-io.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (34 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 4a9db4943b..2274e4f12b 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -44087,6 +44087,29 @@ I/O programming.")
("rust-futures-core-preview" ,rust-futures-core-preview-0.3)
("rust-futures-io-preview" ,rust-futures-io-preview-0.3))))))

+(define-public rust-smallbitvec-2
+ (package
+ (name "rust-smallbitvec")
+ (version "2.5.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "smallbitvec" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0plrbldsjpwip3afbzd8fgrnvdhizcg5z4ncfqs4q6x4qjflzkkm"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-development-inputs
+ (("rust-bit-vec" ,rust-bit-vec-0.4)
+ ("rust-rand" ,rust-rand-0.4))))
+ (home-page "https://github.com/servo/smallbitvec")
+ (synopsis "A bit vector optimized for size and inline storage")
+ (description "This package provides a bit vector optimized for size and
+inline storage")
+ (license (list license:expat license:asl2.0))))
+
(define-public rust-smallvec-1
(package
(name "rust-smallvec")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 08/31] gnu: node: Patch /usr/bin/env in node-gyp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-8-pierre.langlois@gmx.com
* gnu/packages/node.scm (node)[arguments]: Fix /usr/bin/env shebang in
node-gyp.js.
(node-lts)[arguments]: Ditto.
---
gnu/packages/node.scm | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

Toggle diff (35 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 36c45e9c7a..522d4943d0 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -6,7 +6,7 @@
;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018, 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
-;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020, 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;;
@@ -120,6 +120,10 @@
(("'/usr/bin/env'")
(string-append "'" (which "env") "'")))

+ ;; Fix /usr/bin/env shebang in node-gyp.
+ (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
+ (("#!/usr/bin/env") (string-append "#!" (which "env"))))
+
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
@@ -661,6 +665,10 @@ source files.")
(("'/usr/bin/env'")
(string-append "'" (which "env") "'")))

+ ;; Fix /usr/bin/env shebang in node-gyp.
+ (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
+ (("#!/usr/bin/env") (string-append "#!" (which "env"))))
+
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 07/31] gnu: Add tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-7-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Register it.
---
gnu/local.mk | 1 +
gnu/packages/tree-sitter.scm | 98 ++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+)
create mode 100644 gnu/packages/tree-sitter.scm

Toggle diff (116 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 3f09b167b1..3763df0821 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -559,6 +559,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/tls.scm \
%D%/packages/tmux.scm \
%D%/packages/tor.scm \
+ %D%/packages/tree-sitter.scm \
%D%/packages/tv.scm \
%D%/packages/uglifyjs.scm \
%D%/packages/uml.scm \
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
new file mode 100644
index 0000000000..2c749dc0a8
--- /dev/null
+++ b/gnu/packages/tree-sitter.scm
@@ -0,0 +1,98 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages tree-sitter)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system cargo)
+ #:use-module (guix git-download)
+ #:use-module (guix packages)
+ #:use-module (gnu packages crates-io)
+ #:use-module (gnu packages crates-graphics))
+
+(define-public tree-sitter
+ (package
+ (name "tree-sitter")
+ (version "0.19.5")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1qmb0sva28zv6r3c3j7xs9pc8bpwwhkb9vxxndw2zbdn9wkvmbmn"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(;; Running test requires downloading fixtures, see the
+ ;; script/fetch-fixtures script.
+ #:tests? #f
+ ;; FIXME: Installing the sources for the tree-sitter Rust bindings
+ ;; doesn't work out of the box due to tree-sitter having multiple
+ ;; Rust packages in the same repository (bindings and CLI).
+ #:install-source? #f
+ #:cargo-inputs
+ (("rust-ansi-term" ,rust-ansi-term-0.12)
+ ("rust-atty" ,rust-atty-0.2)
+ ("rust-clap" ,rust-clap-2)
+ ("rust-difference" ,rust-difference-2)
+ ("rust-dirs" ,rust-dirs-3)
+ ("rust-html-escape" ,rust-html-escape-0.2)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-smallbitvec" ,rust-smallbitvec-2)
+ ("rust-spin" ,rust-spin-0.7)
+ ("rust-tiny-http" ,rust-tiny-http-0.8)
+ ("rust-walkdir" ,rust-walkdir-2)
+ ("rust-webbrowser" ,rust-webbrowser-0.5)
+ ("rust-which" ,rust-which-4))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'delete-cargo.lock
+ (lambda _ (delete-file "Cargo.lock")))
+ (add-after 'build 'build-lib
+ (lambda _ (invoke "make")))
+ (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)
+ (setenv "PREFIX" out)
+ (invoke "make" "install")))))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Incremental parsing system for programming tools")
+ (description "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @command{tree-sitter} tool as well as the runtime
+library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 10/31] gnu: Add node-nan.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-10-pierre.langlois@gmx.com
---
gnu/packages/node-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (48 lines)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index cbb68f77d6..eb4b59d1ab 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021 Charles <charles.b.jackson@protonmail.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -171,6 +172,35 @@ user-land JavaScript.")
random number generator.")
(license license:bsd-3)))

+(define-public node-nan
+ (package
+ (name "node-nan")
+ (version "2.15.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/nan")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "18xslh9va5ld872scrp5y4251ax9s3c6qh0lnl1200lpzbsxy7yd"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:tests? #f ; FIXME: tests depend on node-tap
+ #:phases
+ (modify-phases %standard-phases
+ ;; The default configure phase fails due to tap being missing, as we do
+ ;; not have tap packaged yet. It is used only for tests. This package
+ ;; still works as a dependency of node-glob and node-inflight.
+ (delete 'configure))))
+ (home-page "https://github.com/nodejs/nan")
+ (synopsis "Native Abstractions for Node.js")
+ (description "This package provides header files filled with macros and
+utilities for making add-on development for Node.js easier across versions.")
+ (license license:bsd-3)))
+
(define-public node-oop
;; No releases, last commit was February 2013.
(let ((commit "f9d87cda0958886955c14a0a716e57021ed295dc")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 12/31] gnu: Add tree-sitter-cpp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-12-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-cpp): New variable.
---
gnu/packages/tree-sitter.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (32 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index c855cba347..ac4fe5c578 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -157,3 +157,27 @@ library.")
(description
"This package provides a C grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-cpp
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-cpp")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-cpp")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "08ywv6n80sa541rr08bqz4zyg7byvjcabp68lvxmcahjk8xzcgwk"))))
+ (native-inputs
+ `(("tree-sitter" ,tree-sitter)
+ ("tree-sitter-c" ,tree-sitter-c)
+ ("node-nan" ,node-nan)))
+ (home-page "https://github.com/tree-sitter/tree-sitter-cpp")
+ (synopsis "Tree-sitter C++ grammar")
+ (description
+ "This package provides a C++ grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 11/31] gnu: Add tree-sitter-c.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-11-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-c): New variable.
---
gnu/packages/tree-sitter.scm | 63 +++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)

Toggle diff (81 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 2c749dc0a8..c855cba347 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -19,10 +19,12 @@
(define-module (gnu packages tree-sitter)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
+ #:use-module (guix build-system node)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (gnu packages crates-io)
- #:use-module (gnu packages crates-graphics))
+ #:use-module (gnu packages crates-graphics)
+ #:use-module (gnu packages node-xyz))

(define-public tree-sitter
(package
@@ -96,3 +98,62 @@ can be embedded in any application.
This package includes the @command{tree-sitter} tool as well as the runtime
library.")
(license license:expat)))
+
+(define-public tree-sitter-c
+ (package
+ (name "tree-sitter-c")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-c")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1diys8yigvhm4ppbmp3a473yxjg2d5lk11y0ay7qprcz7233lakv"))))
+ (build-system node-build-system)
+ (native-inputs
+ `(("tree-sitter" ,tree-sitter)
+ ("node-nan" ,node-nan)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ ;; tree-sitter-cli is listed as a Node.js dependency, however the
+ ;; node tree-sitter-cli package is just a wrapper which downloads a
+ ;; tree-sitter binary, see
+ ;; https://github.com/tree-sitter/tree-sitter/tree/master/cli/npm
+ ;; Instead we remove it as a dependency so that we can use our own
+ ;; tree-sitter package.
+ (add-after 'unpack 'fix-configure
+ (lambda _
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (use-modules ((guix build json)))
+ (let ((package-meta (read-json in)))
+ (assoc-remove! (assoc-ref package-meta "devDependencies")
+ "tree-sitter-cli")
+ (write-json package-meta out))))))
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC" "gcc")))
+ (add-before 'build 'make-files-writable
+ (lambda _
+ (for-each make-file-writable (find-files "src" ".*"))))
+ (add-after 'install 'install-native-lib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out")
+ "/lib/tree-sitter")))
+ ;; Invoking `tree-sitter test' loads the grammar which
+ ;; compiles it to a .so binary that we install.
+ (invoke "tree-sitter" "test")
+ (mkdir-p lib)
+ (copy-recursively (string-append (getenv "HOME")
+ "/.tree-sitter/bin")
+ lib)))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-c")
+ (synopsis "Tree-sitter C grammar")
+ (description
+ "This package provides a C grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 13/31] gnu: Add tree-sitter-css.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-13-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-css): New variable.
---
gnu/packages/tree-sitter.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index ac4fe5c578..05929a9062 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -181,3 +181,23 @@ library.")
(description
"This package provides a C++ grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-css
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-css")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-css")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "014jrlgi7zfza9g38hsr4vlbi8964i5p7iglaih6qmzaiml7bja2"))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-css")
+ (synopsis "Tree-sitter CSS grammar")
+ (description
+ "This package provides a CSS grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 09/31] guix: node-build-system: Support compiling addons with node-gyp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-9-pierre.langlois@gmx.com
* gnu/packages/node.scm (node-headers): New function.
* guix/build-system/node.scm (python): New function.
(node-headers): New function.
(lower): Add node-headers and python to build inputs.
* guix/build/node-build-system.scm (configure-gyp): New function.
(%standard-phases): Add 'configure-gyp after 'configure.
---
gnu/packages/node.scm | 19 ++++++++++++++++++-
guix/build-system/node.scm | 16 ++++++++++++++++
guix/build/node-build-system.scm | 15 +++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)

Toggle diff (111 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 522d4943d0..d0f7c5cdb7 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -48,7 +48,24 @@
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages tls)
- #:use-module (gnu packages web))
+ #:use-module (gnu packages web)
+ #:use-module (ice-9 match)
+ #:export (node-headers))
+
+(define (node-headers node)
+ "Return an <origin> object for a tarball with headers for the given node
+package version."
+ (let* ((version (package-version node))
+ (hash (match version
+ ("10.24.0"
+ "0h37zjwcpxjdqcxqjfj5zp1n5zjxaa0g8lsy83955afg5cca8p0n")
+ ("14.16.0"
+ "1vpdgq7kcw1a0w90lpvbvxbrc0n3pwjrs3sm42pjj7560clvji2b"))))
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://nodejs.org/dist/v" version
+ "/node-v" version "-headers.tar.gz"))
+ (sha256 (base32 hash)))))

(define-public node
(package
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 98f63f87ef..7828582a9a 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -41,6 +42,19 @@
(let ((node (resolve-interface '(gnu packages node))))
(module-ref node 'node-lts)))

+(define (python)
+ "Return the python package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages python))))
+ (module-ref module 'python-wrapper)))
+
+(define (node-headers node)
+ "Return a tarball with headers for the given node, needed for packages that
+need to build native bindings using node-gyp."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages node))))
+ ((module-ref module 'node-headers) node)))
+
(define* (lower name
#:key source inputs native-inputs outputs system target
(node (default-node))
@@ -62,6 +76,8 @@
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ("node-headers" ,(node-headers node))
+ ("python" ,(python))
,@native-inputs))
(outputs outputs)
(build node-build)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..2993c49b2b 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -101,6 +102,19 @@
(invoke npm "--offline" "--ignore-scripts" "install")
#t))

+(define* (configure-gyp #:key inputs #:allow-other-keys)
+ "Run 'node-gyp configure' if we see a 'binding.gyp' file.
+
+By default, 'node-gyp' will try to download node headers from the internet, we
+prevent this with the '--tarball' flag."
+ (let ((node-gyp (string-append (assoc-ref inputs "node")
+ "/lib/node_modules/npm/node_modules/node-gyp"
+ "/bin/node-gyp.js")))
+ (if (file-exists? "binding.gyp")
+ (invoke node-gyp "--tarball" (assoc-ref inputs "node-headers")
+ "configure"))
+ #t))
+
(define* (build #:key inputs #:allow-other-keys)
(let ((package-meta (call-with-input-file "package.json" read-json)))
(if (and=> (assoc-ref package-meta "scripts")
@@ -147,6 +161,7 @@
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
(replace 'configure configure)
+ (add-after 'configure 'configure-gyp configure-gyp)
(replace 'build build)
(replace 'check check)
(add-before 'install 'repack repack)
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 14/31] gnu: Add tree-sitter-go.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-14-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-go): New variable.
---
gnu/packages/tree-sitter.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 05929a9062..f163efd7a3 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -22,6 +22,7 @@
#:use-module (guix build-system node)
#:use-module (guix git-download)
#:use-module (guix packages)
+ #:use-module (guix utils)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages node-xyz))
@@ -201,3 +202,32 @@ library.")
(description
"This package provides a CSS grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-go
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-go")
+ (version "0.19.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-go")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0nxs47vd2fc2fr0qlxq496y852rwg39flhg334s7dlyq7d3lcx4x"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-go")
+ (synopsis "Tree-sitter Go grammar")
+ (description
+ "This package provides a Golang grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 15/31] gnu: Add tree-sitter-html.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-15-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-html): New variable.
---
gnu/packages/tree-sitter.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index f163efd7a3..c2ca5a842a 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -231,3 +231,23 @@ library.")
(description
"This package provides a Golang grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-html
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-html")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-html")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1hg7vbcy7bir6b8x11v0a4x0glvqnsqc3i2ixiarbxmycbgl3axy"))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-html")
+ (synopsis "Tree-sitter HTML grammar")
+ (description
+ "This package provides a HTML grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 16/31] gnu: Add tree-sitter-java.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-16-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-java): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index c2ca5a842a..e671c3fbf9 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -251,3 +251,32 @@ library.")
(description
"This package provides a HTML grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-java
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-java")
+ (version "0.19.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-java")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "07zw9ygb45hnvlx9qlz7rlz8hc3byjy03d24v72i5iyhpiiwlhvl"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-java")
+ (synopsis "Tree-sitter Java grammar")
+ (description
+ "This package provides a Java grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 17/31] gnu: Add tree-sitter-javascript.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-17-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-javascript): New variable.
---
gnu/packages/tree-sitter.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (38 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index e671c3fbf9..e59a44c521 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -280,3 +280,33 @@ library.")
(description
"This package provides a Java grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-javascript
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-javascript")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-javascript")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "063va0s727yzhy1cz04fipzwwbq4af6fhgka6g970hk9yf7ggmnj"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-javascript")
+ (synopsis "Tree-sitter Javascript grammar")
+ (description
+ "This package provides a Javascript grammar for the Tree-sitter
+library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 18/31] gnu: Add tree-sitter-json.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-18-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-json): New variable.
---
gnu/packages/tree-sitter.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index e59a44c521..d6214de2ec 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -310,3 +310,23 @@ library.")
"This package provides a Javascript grammar for the Tree-sitter
library.")
(license license:expat)))
+
+(define-public tree-sitter-json
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-json")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-json")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "06pjh31bv9ja9hlnykk257a6zh8bsxg2fqa54al7qk1r4n9ksnff"))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-json")
+ (synopsis "Tree-sitter JSON grammar")
+ (description
+ "This package provides a JSON grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 19/31] gnu: Add tree-sitter-julia.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-19-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-julia): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index d6214de2ec..aa72348347 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -330,3 +330,32 @@ library.")
(description
"This package provides a JSON grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-julia
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-julia")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-julia")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1pbnmvhy2gq4vg1b0sjzmjm4s2gsgdjh7h01yj8qrrqbcl29c463"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-julia")
+ (synopsis "Tree-sitter Julia grammar")
+ (description
+ "This package provides a Julia grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:33
[PATCH 20/31] gnu: Add tree-sitter-php.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808233354.6745-20-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-php): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index aa72348347..9f1a30f0cc 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -359,3 +359,32 @@ library.")
(description
"This package provides a Julia grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-php
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-php")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-php")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "17cmybgpprw7w9d2v7lmc6zmr90d70g0jqq279gzg0mpwfzla53s"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-php")
+ (synopsis "Tree-sitter PHP grammar")
+ (description
+ "This package provides a PHP grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 21/31] gnu: Add tree-sitter-python.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-1-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-python): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 9f1a30f0cc..d7c3468035 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -388,3 +388,32 @@ library.")
(description
"This package provides a PHP grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-python
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-python")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-python")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "04b85qxqs64x6nhbpcgrzkbilxaiwvr9yd3h065rynv7rsdg0hii"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-python")
+ (synopsis "Tree-sitter Python grammar")
+ (description
+ "This package provides a Python grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 22/31] gnu: Add tree-sitter-rust.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-2-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-rust): New variable.
---
gnu/packages/tree-sitter.scm | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

Toggle diff (40 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index d7c3468035..6c2b2e7577 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -23,6 +23,7 @@
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (gnu packages algebra)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages node-xyz))
@@ -417,3 +418,27 @@ library.")
(description
"This package provides a Python grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-rust
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-rust")
+ (version "0.19.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-rust")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "118vkhv7n3sw8y9pi0987cgdcd74sjqwviijw01mhnk3bkyczi3l"))))
+ (native-inputs
+ `(("bc" ,bc)
+ ("tree-sitter" ,tree-sitter)
+ ("node-nan" ,node-nan)))
+ (home-page "https://github.com/tree-sitter/tree-sitter-rust")
+ (synopsis "Tree-sitter Rust grammar")
+ (description
+ "This package provides a Rust grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 24/31] gnu: Add rust-bindgen@0.56.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-4-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-bindgen-0.56): New variable.
---
gnu/packages/crates-io.scm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)

Toggle diff (48 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index b551e6921d..44f8885adb 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -4482,6 +4482,43 @@ bindings to C and C++ libraries.")
("rust-shlex" ,rust-shlex-0.1)
("rust-which" ,rust-which-3))))))

+(define-public rust-bindgen-0.56
+ (package
+ (inherit rust-bindgen-0.57)
+ (name "rust-bindgen")
+ (version "0.56.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "bindgen" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0fajmgk2064ca1z9iq1jjkji63qwwz38z3d67kv6xdy0xgdpk8rd"))))
+ (arguments
+ `(#:skip-build? #t
+ #:cargo-inputs
+ (("rust-bitflags" ,rust-bitflags-1)
+ ("rust-cexpr" ,rust-cexpr-0.4)
+ ("rust-cfg-if" ,rust-cfg-if-0.1)
+ ("rust-clang-sys" ,rust-clang-sys-1)
+ ("rust-clap" ,rust-clap-2)
+ ("rust-env-logger" ,rust-env-logger-0.8)
+ ("rust-lazy-static" ,rust-lazy-static-1)
+ ("rust-lazycell" ,rust-lazycell-1)
+ ("rust-log" ,rust-log-0.4)
+ ("rust-peeking-take-while" ,rust-peeking-take-while-0.1)
+ ("rust-proc-macro2" ,rust-proc-macro2-1)
+ ("rust-quote" ,rust-quote-1)
+ ("rust-regex" ,rust-regex-1)
+ ("rust-rustc-hash" ,rust-rustc-hash-1)
+ ("rust-shlex" ,rust-shlex-0.1)
+ ("rust-which" ,rust-which-3))
+ #:cargo-development-inputs
+ (("rust-clap" ,rust-clap-2)
+ ("rust-diff" ,rust-diff-0.1)
+ ("rust-shlex" ,rust-shlex-0.1))))))
+
(define-public rust-bindgen-0.55
(package
(inherit rust-bindgen-0.57)
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 23/31] gnu: Add tree-sitter-typescript.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-3-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-typescript): New variable.
---
gnu/packages/tree-sitter.scm | 60 ++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)

Toggle diff (68 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 6c2b2e7577..0f1946a77e 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -442,3 +442,63 @@ library.")
(description
"This package provides a Rust grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-typescript
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-typescript")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-typescript")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "01pkmwwmbv6kxda0n6g4cfg72ldmpi9gmp11a5gygn472vhrh2xw"))))
+ (native-inputs
+ `(("tree-sitter" ,tree-sitter)
+ ("tree-sitter-javascript" ,tree-sitter-javascript)
+ ("node-nan" ,node-nan)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))
+ (add-after 'build 'build-gyp
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((node (assoc-ref inputs "node")))
+ (invoke (string-append node "/lib/node_modules/npm/node_modules"
+ "/node-gyp/bin/node-gyp.js")
+ "build"))))
+ (replace 'make-files-writable
+ (lambda _
+ (for-each make-file-writable
+ (find-files "typescript" ".*"))
+ (for-each make-file-writable
+ (find-files "tsx" ".*"))))
+ (replace 'install-native-lib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out")
+ "/lib/tree-sitter")))
+ ;; Invoking `tree-sitter test' loads the grammar which
+ ;; compiles it to a .so binary that we install.
+ (with-directory-excursion "typescript"
+ (invoke "tree-sitter" "test"))
+ (with-directory-excursion "tsx"
+ (invoke "tree-sitter" "test"))
+ (mkdir-p lib)
+ (copy-recursively (string-append (getenv "HOME")
+ "/.tree-sitter/bin")
+ lib))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-typescript")
+ (synopsis "Tree-sitter Typescript grammar")
+ (description
+ "This package provides Typescript and TSX grammars for the Tree-sitter
+library.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 26/31] gnu: rust-emacs-module: Update to 0.16.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-6-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-module-0.16): New variable.
(rust-emacs-module-0.10): Inherit from rust-emacs-module-0.10.
---
gnu/packages/crates-io.scm | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 44f8885adb..57a287c5d2 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -14638,10 +14638,10 @@ Emacs' support for dynamic modules.")
(description "This package provides proc macros for Emacs modules.")
(license license:bsd-3)))

-(define-public rust-emacs-module-0.10
+(define-public rust-emacs-module-0.16
(package
(name "rust-emacs-module")
- (version "0.10.0")
+ (version "0.16.2")
(source
(origin
(method url-fetch)
@@ -14650,11 +14650,11 @@ Emacs' support for dynamic modules.")
(string-append name "-" version ".tar.gz"))
(sha256
(base32
- "1gf9lz735xbkyir53dyv362drfx3nin5an5cx39kd8q8kjjwix5g"))))
+ "0s8qrh0ggjmqr04zkcf7s4ijmpd44rjcag78npnq64jv10lxvsry"))))
(build-system cargo-build-system)
(arguments
`(#:cargo-inputs
- (("rust-bindgen" ,rust-bindgen-0.48))))
+ (("rust-bindgen" ,rust-bindgen-0.56))))
(inputs
`(("clang" ,clang)))
(home-page "https://github.com/ubolonton/emacs-module-rs")
@@ -14663,6 +14663,23 @@ Emacs' support for dynamic modules.")
Emacs' support for dynamic modules.")
(license license:bsd-3)))

+(define-public rust-emacs-module-0.10
+ (package (inherit rust-emacs-module-0.16)
+ (name "rust-emacs-module")
+ (version "0.10.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs_module" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1gf9lz735xbkyir53dyv362drfx3nin5an5cx39kd8q8kjjwix5g"))))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-bindgen" ,rust-bindgen-0.48))))))
+
(define-public rust-embed-resource-1
(package
(name "rust-embed-resource")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 25/31] gnu: Add rust-tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-5-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (rust-tree-sitter): New variable.
---
gnu/packages/tree-sitter.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 0f1946a77e..4817b293ce 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -20,6 +20,7 @@
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
#:use-module (guix build-system node)
+ #:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
@@ -101,6 +102,32 @@ This package includes the @command{tree-sitter} tool as well as the runtime
library.")
(license license:expat)))

+(define-public rust-tree-sitter-0.19
+ (package
+ (name "rust-tree-sitter")
+ (version "0.19.5")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "tree-sitter" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1h6adq5kqf4izzsklch5lfxx2aisxga463zz7w44rgwnck16wwmd"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:tests? #f ;; Running tests misinterprets comments as doc-tests.
+ #:cargo-inputs
+ (("rust-cc" ,rust-cc-1)
+ ("rust-lazy-static" ,rust-lazy-static-1)
+ ("rust-regex" ,rust-regex-1)
+ ("rust-spin" ,rust-spin-0.7))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Rust bindings to the Tree-sitter parsing library")
+ (description "This package provides Rust bindings to the Tree-sitter
+parsing library.")
+ (license license:expat)))
+
(define-public tree-sitter-c
(package
(name "tree-sitter-c")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 27/31] gnu: rust-emacs-macros: Update to 0.17.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-7-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-macros-0.17): New variable.
(rust-emacs-macros-0.11): Inherit from rust-emacs-macros-0.17.
---
gnu/packages/crates-io.scm | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 57a287c5d2..365cd6dcb1 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -14614,8 +14614,31 @@ signing, and verification in pure Rust.")
Emacs' support for dynamic modules.")
(license license:bsd-3)))

-(define-public rust-emacs-macros-0.11
+(define-public rust-emacs-macros-0.17
(package
+ (name "rust-emacs-macros")
+ (version "0.17.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs-macros" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0qg1dcn5acbirq617qq2fgg9adswif2dnr292s3qnq62wzgnyrb9"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-darling" ,rust-darling-0.10)
+ ("rust-quote" ,rust-quote-1)
+ ("rust-syn" ,rust-syn-1))))
+ (home-page "https://github.com/ubolonton/emacs-module-rs")
+ (synopsis "Proc macros for Emacs modules")
+ (description "This package provides proc macros for Emacs modules.")
+ (license license:bsd-3)))
+
+(define-public rust-emacs-macros-0.11
+ (package (inherit rust-emacs-macros-0.17)
(name "rust-emacs-macros")
(version "0.11.0")
(source
@@ -14627,16 +14650,11 @@ Emacs' support for dynamic modules.")
(sha256
(base32
"0390y8vafxdi334hhgrzvcqjq3n5ckcmvilqcfp8vajjq8irrly6"))))
- (build-system cargo-build-system)
(arguments
`(#:cargo-inputs
(("rust-darling" ,rust-darling-0.9)
("rust-quote" ,rust-quote-0.6)
- ("rust-syn" ,rust-syn-0.15))))
- (home-page "https://github.com/ubolonton/emacs-module-rs")
- (synopsis "Proc macros for Emacs modules")
- (description "This package provides proc macros for Emacs modules.")
- (license license:bsd-3)))
+ ("rust-syn" ,rust-syn-0.15))))))

(define-public rust-emacs-module-0.16
(package
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 28/31] gnu: rust-emacs: Update to 0.17.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-8-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-0.17): New variable.
(rust-emacs-0.11): Inherit from rust-emacs-0.17.
---
gnu/packages/crates-io.scm | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)

Toggle diff (70 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 365cd6dcb1..6b7dbe689c 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -14583,10 +14583,10 @@ signing, and verification in pure Rust.")
@code{Right} is a general purpose sum type with two cases.")
(license (list license:expat license:asl2.0))))

-(define-public rust-emacs-0.11
+(define-public rust-emacs-0.17
(package
(name "rust-emacs")
- (version "0.11.0")
+ (version "0.17.0")
(source
(origin
(method url-fetch)
@@ -14595,16 +14595,18 @@ signing, and verification in pure Rust.")
(string-append name "-" version ".tar.gz"))
(sha256
(base32
- "1xn6nr8m3p24irlmv3i7c9n95yb10qc6aikwqv99qlmhbky5x0z7"))))
+ "02f31apvz03dr0dwn5wyirdmqkk2d635iki0kmsh291xr6dysy2q"))))
(build-system cargo-build-system)
(arguments
`(#:cargo-inputs
- (("rust-ctor" ,rust-ctor-0.1)
- ("rust-emacs-macros" ,rust-emacs-macros-0.11)
- ("rust-emacs-module" ,rust-emacs-module-0.10)
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-ctor" ,rust-ctor-0.1)
+ ("rust-emacs-macros" ,rust-emacs-macros-0.17)
+ ("rust-emacs-module" ,rust-emacs-module-0.16)
("rust-failure" ,rust-failure-0.1)
("rust-failure-derive" ,rust-failure-derive-0.1)
- ("rust-lazy-static" ,rust-lazy-static-1))))
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-thiserror" ,rust-thiserror-1))))
(inputs
`(("clang" ,clang)))
(home-page "https://github.com/ubolonton/emacs-module-rs")
@@ -14614,6 +14616,28 @@ signing, and verification in pure Rust.")
Emacs' support for dynamic modules.")
(license license:bsd-3)))

+(define-public rust-emacs-0.11
+ (package (inherit rust-emacs-0.17)
+ (name "rust-emacs")
+ (version "0.11.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1xn6nr8m3p24irlmv3i7c9n95yb10qc6aikwqv99qlmhbky5x0z7"))))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-ctor" ,rust-ctor-0.1)
+ ("rust-emacs-macros" ,rust-emacs-macros-0.11)
+ ("rust-emacs-module" ,rust-emacs-module-0.10)
+ ("rust-failure" ,rust-failure-0.1)
+ ("rust-failure-derive" ,rust-failure-derive-0.1)
+ ("rust-lazy-static" ,rust-lazy-static-1))))))
+
(define-public rust-emacs-macros-0.17
(package
(name "rust-emacs-macros")
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 29/31] gnu: Add emacs-tree-sitter-core.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-9-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable.
(emacs-tree-sitter-core): New variable.
---
gnu/packages/tree-sitter.scm | 79 ++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)

Toggle diff (101 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 4817b293ce..a9c1714936 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -19,6 +19,7 @@
(define-module (gnu packages tree-sitter)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
+ #:use-module (guix build-system emacs)
#:use-module (guix build-system node)
#:use-module (guix download)
#:use-module (guix git-download)
@@ -27,6 +28,7 @@
#:use-module (gnu packages algebra)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages crates-graphics)
+ #:use-module (gnu packages llvm)
#:use-module (gnu packages node-xyz))

(define-public tree-sitter
@@ -529,3 +531,80 @@ library.")
"This package provides Typescript and TSX grammars for the Tree-sitter
library.")
(license license:expat)))
+
+;; Local package definition solely for building the native emacs module
+;; written in Rust.
+(define tree-sitter-emacs-module
+ (package
+ (name "tree-sitter-emacs-module")
+ (version "0.15.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "15y0wjnck8rbfhl0xrl71ci7clbcp11lhqil5l8ykprsdjv0c2as"))))
+ (build-system cargo-build-system)
+ (inputs
+ `(("clang" ,clang)))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-emacs" ,rust-emacs-0.17)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-tree-sitter" ,rust-tree-sitter-0.19))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'delete-cargo.lock
+ (lambda _ (delete-file "Cargo.lock")))
+ (add-after 'delete-cargo.lock 'do-not-fetch-from-github
+ (lambda _
+ (substitute* "Cargo.toml"
+ (("\\[patch.*") "")
+ (("git = .*") ""))))
+ (add-after 'do-not-fetch-from-github 'chdir
+ (lambda _ (chdir "core")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
+ (install-file "../target/release/libtsc_dyn.so" lib)))))))
+ (home-page #f)
+ (synopsis #f)
+ (description #f)
+ (license license:expat)))
+
+(define-public emacs-tree-sitter-core
+ (package
+ (name "emacs-tree-sitter-core")
+ (version (package-version tree-sitter-emacs-module))
+ (source (package-source tree-sitter-emacs-module))
+ (build-system emacs-build-system)
+ (native-inputs
+ `(("tree-sitter-emacs-module" ,tree-sitter-emacs-module)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "core")))
+ (add-after 'install 'install-module
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out")))
+ (module (string-append (assoc-ref inputs "tree-sitter-emacs-module")
+ "/lib/libtsc_dyn.so")))
+ ;; Writing "LOCAL" in this file prevents the package from
+ ;; trying to download the module from the internet.
+ (call-with-output-file (string-append elpa "/DYN-VERSION")
+ (lambda (port) (display "LOCAL" port)))
+ (substitute* "tsc-dyn-get.el"
+ (("defcustom tsc-dyn-dir tsc--dir")
+ (string-append "defcustom tsc-dyn-dir \"" elpa "\"")))
+ (copy-file module (string-append elpa "/tsc-dyn.so"))))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp, core library")
+ (description "This package provides core APIs of the Emacs binding for
+Tree-sitter, an incremental parsing system.")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 30/31] gnu: Add emacs-tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-10-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (emacs-tree-sitter): New variable.
---
gnu/packages/tree-sitter.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index a9c1714936..22551d4482 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -608,3 +608,30 @@ library.")
(description "This package provides core APIs of the Emacs binding for
Tree-sitter, an incremental parsing system.")
(license license:expat)))
+
+(define-public emacs-tree-sitter
+ (package
+ (name "emacs-tree-sitter")
+ (version (package-version emacs-tree-sitter-core))
+ (source (package-source emacs-tree-sitter-core))
+ (build-system emacs-build-system)
+ (propagated-inputs
+ `(("emacs-tree-sitter-core" ,emacs-tree-sitter-core)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "lisp"))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp")
+ (description "This package provides Emacs bindings for Tree-sitter, an
+incremental parsing library. It aims to be the foundation for a new breed of
+Emacs packages that understand code structurally. For example:
+
+@enumerate
+@item Faster, fine-grained code highlighting.
+@item More flexible code folding.
+@item Structural editing (like Paredit, or even better) for non-Lisp code.
+@item More informative indexing for imenu.
+@end enumerate")
+ (license license:expat)))
--
2.32.0
P
P
Pierre Langlois wrote on 9 Aug 2021 01:43
[PATCH 31/31] gnu: Add emacs-tree-sitter-langs.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210808234358.7241-11-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (emacs-tree-sitter-langs): New variable.
---
gnu/packages/tree-sitter.scm | 79 ++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)

Toggle diff (87 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 22551d4482..bfdfacf122 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -635,3 +635,82 @@ Emacs packages that understand code structurally. For example:
@item More informative indexing for imenu.
@end enumerate")
(license license:expat)))
+
+(define-public emacs-tree-sitter-langs
+ (package
+ (name "emacs-tree-sitter-langs")
+ (version "0.10.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/tree-sitter-langs")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0lym09jnlb7kvqkwkjbrqpc24fkpv99f8r9139sw8g537yj5f8rq"))))
+ (build-system emacs-build-system)
+ ;; FIXME: Support for some languages, such as bash, is still missing from
+ ;; the bundle.
+ (inputs
+ `(("tree-sitter-c" ,tree-sitter-c)
+ ("tree-sitter-cpp" ,tree-sitter-cpp)
+ ("tree-sitter-css" ,tree-sitter-css)
+ ("tree-sitter-go" ,tree-sitter-go)
+ ("tree-sitter-html" ,tree-sitter-html)
+ ("tree-sitter-java" ,tree-sitter-java)
+ ("tree-sitter-javascript" ,tree-sitter-javascript)
+ ("tree-sitter-json" ,tree-sitter-json)
+ ("tree-sitter-julia" ,tree-sitter-julia)
+ ("tree-sitter-php" ,tree-sitter-php)
+ ("tree-sitter-python" ,tree-sitter-python)
+ ("tree-sitter-rust" ,tree-sitter-rust)
+ ("tree-sitter-typescript" ,tree-sitter-typescript)))
+ (propagated-inputs
+ `(("emacs-tree-sitter" ,emacs-tree-sitter)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'build 'fake-bundle
+ (lambda _
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file "bin/BUNDLE-VERSION"
+ (lambda (port) (display ,version port)))))
+ (add-after 'install 'install-libs
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (define (install-lib lang)
+ (let ((input (assoc-ref inputs (string-append "tree-sitter-" lang))))
+ (copy-file (string-append input "/lib/tree-sitter/" lang ".so")
+ (string-append elpa "/bin/" lang ".so"))))
+ (mkdir-p (string-append elpa "/bin"))
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file (string-append elpa "/bin/BUNDLE-VERSION")
+ (lambda (port) (display ,version port)))
+ (for-each (lambda (input)
+ (use-modules (ice-9 regex))
+ (cond
+ ((string-match "^tree-sitter-(.*)$" (car input))
+ => (lambda (m)
+ (install-lib (match:substring m 1))))))
+ inputs))))
+ (add-after 'install 'install-queries
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (copy-recursively "queries" (string-append elpa "/queries"))))))))
+ (home-page "https://ubolonton.github.io/emacs-tree-sitter/languages/")
+ (synopsis "Language support bundle for Tree-sitter")
+ (description "This package is a convenient language bundle for
+Tree-sitter. For each supported language, this package provides:
+
+@enumerate
+@item Pre-compiled grammar binaries.
+@item An optional highlights.scm file that provides highlighting patterns.
+This is mainly intended for major modes that are not aware of tree-sitter.
+@item Optional query patterns for other minor modes that provide high-level
+functionalities on top of tree-sitter, such as code folding, evil text
+objects, ...etc.
+@end enumerate")
+ (license license:expat)))
--
2.32.0
M
M
Maxime Devos wrote on 10 Aug 2021 20:28
Re: [bug#49946] [PATCH 08/31] gnu: node: Patch /usr/bin/env in node-gyp.
42e10baddb6afe308f67c3240bf5da8159e6f118.camel@telenet.be
Pierre Langlois schreef op ma 09-08-2021 om 00:33 [+0100]:
Toggle quote (8 lines)
> @@ -120,6 +120,10 @@
> (("'/usr/bin/env'")
> (string-append "'" (which "env") "'")))
>
> + ;; Fix /usr/bin/env shebang in node-gyp.
> + (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
> + (("#!/usr/bin/env") (string-append "#!" (which "env"))))

For cross-compilation, this should most likely be
(string-append (assoc-ref inputs "coreutils") "/bin/env")
or something like that instead. Likewise in other places.
The old code uses (which "env") in some cases, but those
are probably wrong (except where it is patched in tests).

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYRLFaRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7jcOAQCV9XqauiR9WpI550tltw8xH4Wv
lvGKYPnUb14G5U/W3gEA6sDJnEtt6s7Ag/t6AerN4qI28JQeCxQ0LkrLhz4nzQ0=
=80uq
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 10 Aug 2021 20:30
Re: [bug#49946] [PATCH 11/31] gnu: Add tree-sitter-c.
fd74360c5ce59c7800d1ee528036d43a4a9fec32.camel@telenet.be
Pierre Langlois schreef op ma 09-08-2021 om 00:33 [+0100]:
Toggle quote (2 lines)
> + (setenv "CC" "gcc")))

Use (setenv "CC" ,(cc-for-target)) instead,
such that the cross-compiler TARGET-gcc is used
when cross-compiling.

reetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYRLFxxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7pqsAP93DYjd22Jnvq86nV9t/Fc0ePrv
JFHBVxHk0H3v68M7VAD9Fo4kKgqsuDWUqyiahLhV81pHRrSIMHEGpAIMVxqp8Q0=
=uvuY
-----END PGP SIGNATURE-----


P
P
Pierre Langlois wrote on 11 Aug 2021 17:36
Re: [bug#49946] [PATCH 08/31] gnu: node: Patch /usr/bin/env in node-gyp.
(name . Maxime Devos)(address . maximedevos@telenet.be)
87czqkng4k.fsf@gmx.com
Hi Maxime,

Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (16 lines)
> [[PGP Signed Part:Undecided]]
> Pierre Langlois schreef op ma 09-08-2021 om 00:33 [+0100]:
>> @@ -120,6 +120,10 @@
>> (("'/usr/bin/env'")
>> (string-append "'" (which "env") "'")))
>>
>> + ;; Fix /usr/bin/env shebang in node-gyp.
>> + (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
>> + (("#!/usr/bin/env") (string-append "#!" (which "env"))))
>
> For cross-compilation, this should most likely be
> (string-append (assoc-ref inputs "coreutils") "/bin/env")
> or something like that instead. Likewise in other places.
> The old code uses (which "env") in some cases, but those
> are probably wrong (except where it is patched in tests).

Good point, I didn't consider cross-compilation. Actually, trying it,
it looks like our node package doesn't currently cross-compile
correctly. I just managed to get it to cross-compile though, I'll
submit another patch for it! In the meantime, with this series I agree
it's better for the new code to be correct from the begining though.

Thanks for taking a look!
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmET75sYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31U65EH/1viouDCu3YEBTff3X725srp
+kf8oKFE4Vl/cE2uR8Gqolj4ldjYKYiYrf/Mhz5oM4+N2LqaJjaxcs+3dRXV8NrS
51CYHzWmhPu4kMf3LaetK3s/kjauDME80EHaOYDiH9aZn2h6D4QOmHbA/Xs7Oct+
2Ntoz356uMaD6jzluK1ljCmLQyew4TnlnaOzzF4MzJ6mE98noT6MAiMZyWmf7aXv
ax6Zr6f+hJc83TiUAN6hKX4hc/sIGv8c9MwCepNeZZGQHeJvAiw223bIfClXlIPJ
2NPTab5FQ0ypbpDhmmhoZ787yS3SRp18mJuC/PblI9l5WZHd+GR2Bue7kXdl1vY=
=YsOg
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 13 Aug 2021 15:17
Re: [PATCH 07/31] gnu: Add tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
87zgtla2x0.fsf@gmx.com
Pierre Langlois <pierre.langlois@gmx.com> writes:

Toggle quote (68 lines)
> * gnu/packages/tree-sitter.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Register it.
> ---
> gnu/local.mk | 1 +
> gnu/packages/tree-sitter.scm | 98 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 99 insertions(+)
> create mode 100644 gnu/packages/tree-sitter.scm
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 3f09b167b1..3763df0821 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -559,6 +559,7 @@ GNU_SYSTEM_MODULES = \
> %D%/packages/tls.scm \
> %D%/packages/tmux.scm \
> %D%/packages/tor.scm \
> + %D%/packages/tree-sitter.scm \
> %D%/packages/tv.scm \
> %D%/packages/uglifyjs.scm \
> %D%/packages/uml.scm \
> diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
> new file mode 100644
> index 0000000000..2c749dc0a8
> --- /dev/null
> +++ b/gnu/packages/tree-sitter.scm
> @@ -0,0 +1,98 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify it
> +;;; under the terms of the GNU General Public License as published by
> +;;; the Free Software Foundation; either version 3 of the License, or (at
> +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu packages tree-sitter)
> + #:use-module ((guix licenses) #:prefix license:)
> + #:use-module (guix build-system cargo)
> + #:use-module (guix git-download)
> + #:use-module (guix packages)
> + #:use-module (gnu packages crates-io)
> + #:use-module (gnu packages crates-graphics))
> +
> +(define-public tree-sitter
> + (package
> + (name "tree-sitter")
> + (version "0.19.5")
> + (source
> + (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/tree-sitter/tree-sitter")
> + (commit (string-append "v" version))))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32
> + "1qmb0sva28zv6r3c3j7xs9pc8bpwwhkb9vxxndw2zbdn9wkvmbmn"))))
> + (build-system cargo-build-system)

The tree-sitter package here both ships the `tree-sitter' command-line
program, written in Rust, and the runtime library, written in C. I
think it would be better to split this into two packages, `tree-sitter'
for the runtime and `tree-sitter-cli` for the Rust program.

That way, a potential future Emacs will be able to link against
libtree-sitter *without* bringing in Rust as a hard dependency. I saw
that native tree-sitter support was being worked on on emacs-devel
list. One would still need Rust to actually use it, but at least it
remains an optional dependency.

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmEWc7sYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31ULTwH/R+uDT5j6mrUlYW6Q39UKilQ
WzzPPUVLns8eSZmvDX4hJOxO6+qG3X1lprUOVNgRC4DKncMVW36ntYLqJDin+eFo
Smh87p+1K0itjMuriiOU+foMfUxPlZ7oeHbrQD6y3cBmfUAy8J7G/UtZ+ZBb677b
jycusQGkWXaahi6Llh81g+pZuFAp0+pYo33fhlsabAgI1HzuEUsHDXEWUgfJM2Zx
G+vuyAmGyX3jpA/RXHtXXifB+dnhD4NbUsSb+edCLWUG2OcoW9PNakBhloo3O82O
eHibETllS3pAV66m7gFrZ0pM5V3LdW7o4x0qzQXtYgFAbtPiJjNOqf2Gc4y+Zig=
=hY4u
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 29 Aug 2021 12:34
[PATCH v2 00/33] gnu: Add tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
87czpwzg9e.fsf@gmx.com
Hi Guix!

Here's a V2 of the tree-sitter patch series. Changes:

- Split tree-sitter into tree-sitter enacs tree-sitter-cli. This way
applications can link against the tree-sitter runtime without
depending on rust. Emacs may do that in the future :-).
- Fix the node build system changes to work with cross-compilation in
the future.
- Use cc-for-target in tree-sitter-c.
- Add tree-sitter-bash, figured out how to package that one.

Thanks,
Pierre

Pierre Langlois (33):
gnu: rust-chunked-transfer: Update to 1.4.0.
gnu: Add rust-fdlimit.
gnu: Add rust-html-escape.
gnu: Add rust-smallbitvec.
gnu: rust-tiny-http: Update to 0.8.
gnu: rust-spin: Update to 0.7.
gnu: Add tree-sitter.
gnu: Add tree-sitter-cli.
gnu: node: Patch /usr/bin/env in node-gyp.
guix: node-build-system: Support compiling addons with node-gyp.
gnu: Add node-nan.
gnu: Add tree-sitter-c.
gnu: Add tree-sitter-cpp.
gnu: Add tree-sitter-bash.
gnu: Add tree-sitter-css.
gnu: Add tree-sitter-go.
gnu: Add tree-sitter-html.
gnu: Add tree-sitter-java.
gnu: Add tree-sitter-javascript.
gnu: Add tree-sitter-json.
gnu: Add tree-sitter-julia.
gnu: Add tree-sitter-php.
gnu: Add tree-sitter-python.
gnu: Add tree-sitter-rust.
gnu: Add tree-sitter-typescript.
gnu: Add rust-bindgen@0.56.
gnu: Add rust-tree-sitter.
gnu: rust-emacs-module: Update to 0.16.
gnu: rust-emacs-macros: Update to 0.17.
gnu: rust-emacs: Update to 0.17.
gnu: Add emacs-tree-sitter-core.
gnu: Add emacs-tree-sitter.
gnu: Add emacs-tree-sitter-langs.

gnu/local.mk | 1 +
gnu/packages/crates-io.scm | 290 +++++++++--
gnu/packages/node-xyz.scm | 30 ++
gnu/packages/node.scm | 31 +-
gnu/packages/tree-sitter.scm | 791 +++++++++++++++++++++++++++++++
guix/build-system/node.scm | 16 +
guix/build/node-build-system.scm | 15 +
7 files changed, 1141 insertions(+), 33 deletions(-)
create mode 100644 gnu/packages/tree-sitter.scm

--
2.33.0
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmErY+0YHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UtlUH/iGlSOaAWq3oU/Sx2zTpmC/5
cgzSwm0XmUaWSZNHTk30WbflF3HwqoqpBV5g92xpk4vfZbyDyXaqcr5YO6ueJhpc
ga60DiP+GD6edx053mzg+/A7/JdCoVQGag+QXhk3brrO95DNQwq7St+DjhKPvdEa
+9EE9/ePmIJ30cPxWk7zziVMyivD8YqcBc7z5bRpn/jjTh647+98aZ+yzgtTXHyF
+wsG7EBSUNRNoMT9cyqnER0werOVXluSkjvhn6RNKdRJHqSR90QBGYim/jxoIMZH
ZZUavwb4JzfwArS44c/j49h0OoaWIoX8cLZL3fQuPKSYkCX71+NMdB/GgXi6GvA=
=z5lI
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 02/33] gnu: Add rust-fdlimit.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-2-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-fdlimit-0.1): New variable.
---
gnu/packages/crates-io.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (33 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 3e93db1879..bfa14d5297 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -16008,6 +16008,28 @@ it.")
(("rust-libc" ,rust-libc-0.2)
("rust-winapi" ,rust-winapi-0.3))))))

+(define-public rust-fdlimit-0.1
+ (package
+ (name "rust-fdlimit")
+ (version "0.1.4")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "fdlimit" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0g30d6gqkrwy8ylwdy7pqm443iq0p5dmnpz4ks41pirl7dclm98d"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-libc" ,rust-libc-0.2))))
+ (home-page "https://github.com/paritytech/fdlimit")
+ (synopsis "Raise the open file descriptors limit")
+ (description "Utility crate for raising file descriptors limit.")
+ (license license:asl2.0)))
+
(define-public rust-femme-2
(package
(name "rust-femme")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 01/33] gnu: rust-chunked-transfer: Update to 1.4.0.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-1-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-chunked-transfer-1): New variable.
(rust-chunked-transfer-0.3): Inherit from rust-chunked-transfer-1.
---
gnu/packages/crates-io.scm | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

Toggle diff (58 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 087ffa1d27..3e93db1879 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -18,6 +18,7 @@
;;; Copyright © 2021 Antero Mejr <antero@kodmin.com>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -7884,19 +7885,21 @@ Python arrow.humanize.")
TimeZone trait for @code{rust-chrono}.")
(license (list license:expat license:asl2.0))))

-(define-public rust-chunked-transfer-0.3
+(define-public rust-chunked-transfer-1
(package
(name "rust-chunked-transfer")
- (version "0.3.1")
+ (version "1.4.0")
(source
(origin
(method url-fetch)
(uri (crate-uri "chunked_transfer" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
- (base32 "11yghnd24w0i9p8g368c3pg7qh9nfz7kgri6pywja9pnmakj13a9"))))
+ (base32 "0bkdlsrszfcscw3j6yhs7kj6jbp8id47jjk6h9k58px47na5gy7z"))))
(build-system cargo-build-system)
- (arguments `(#:skip-build? #t))
+ (arguments
+ `(#:cargo-development-inputs
+ (("rust-criterion" ,rust-criterion-0.3))))
(home-page "https://github.com/frewsxcv/rust-chunked-transfer")
(synopsis "Encoder and decoder for HTTP chunked transfer coding")
(description
@@ -7904,6 +7907,19 @@ TimeZone trait for @code{rust-chrono}.")
coding.")
(license license:asl2.0)))

+(define-public rust-chunked-transfer-0.3
+ (package (inherit rust-chunked-transfer-1)
+ (name "rust-chunked-transfer")
+ (version "0.3.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "chunked_transfer" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "11yghnd24w0i9p8g368c3pg7qh9nfz7kgri6pywja9pnmakj13a9"))))
+ (arguments `(#:skip-build? #t))))
+
(define-public rust-ci-info-0.3
(package
(name "rust-ci-info")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 03/33] gnu: Add rust-html-escape.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-3-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-html-escape-0.2): New variable.
---
gnu/packages/crates-io.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index bfa14d5297..31136a88e3 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -20921,6 +20921,32 @@ Hash-based Message Authentication Code algorithm} for SHA1.")
"This package provides a library for HTML entity encoding and decoding.")
(license (list license:asl2.0 license:expat license:mpl2.0))))

+(define-public rust-html-escape-0.2
+ (package
+ (name "rust-html-escape")
+ (version "0.2.9")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "html-escape" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1dxw9lpckrqzzqgbkw64ckbajr4b7xxnjdn8adgzqf2mm40shvl1"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-utf8-width" ,rust-utf8-width-0.1))
+ #:cargo-development-inputs
+ (("rust-bencher" ,rust-bencher-0.1))))
+ (home-page "https://magiclen.org/html-escape")
+ (synopsis "Library for encoding and escaping special characters in HTML")
+ (description
+ "This package provides a library for encoding and escaping special
+characters in HTML, decoding and unescaping HTML entities as well.")
+ (license license:expat)))
+
(define-public rust-http-0.2
(package
(name "rust-http")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 04/33] gnu: Add rust-smallbitvec.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-4-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-smallbitvec-2): New variable.
---
gnu/packages/crates-io.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (34 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 31136a88e3..de1b581cbd 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -44429,6 +44429,29 @@ I/O programming.")
("rust-futures-core-preview" ,rust-futures-core-preview-0.3)
("rust-futures-io-preview" ,rust-futures-io-preview-0.3))))))

+(define-public rust-smallbitvec-2
+ (package
+ (name "rust-smallbitvec")
+ (version "2.5.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "smallbitvec" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0plrbldsjpwip3afbzd8fgrnvdhizcg5z4ncfqs4q6x4qjflzkkm"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-development-inputs
+ (("rust-bit-vec" ,rust-bit-vec-0.4)
+ ("rust-rand" ,rust-rand-0.4))))
+ (home-page "https://github.com/servo/smallbitvec")
+ (synopsis "A bit vector optimized for size and inline storage")
+ (description "This package provides a bit vector optimized for size and
+inline storage")
+ (license (list license:expat license:asl2.0))))
+
(define-public rust-smallvec-1
(package
(name "rust-smallvec")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 06/33] gnu: rust-spin: Update to 0.7.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-6-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-spin-0.7): New variable.
(rust-spin-0.5): Inherit from rust-spin-0.7.
---
gnu/packages/crates-io.scm | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

Toggle diff (52 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 07d0a7594e..476d35c241 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -44838,10 +44838,10 @@ track of where each new file and line starts.")
"An RSpec inspired minimal testing framework for Rust.")
(license license:expat)))

-(define-public rust-spin-0.5
+(define-public rust-spin-0.7
(package
(name "rust-spin")
- (version "0.5.2")
+ (version "0.7.1")
(source
(origin
(method url-fetch)
@@ -44849,8 +44849,11 @@ track of where each new file and line starts.")
(file-name (string-append name "-" version ".crate"))
(sha256
(base32
- "0b84m6dbzrwf2kxylnw82d3dr8w06av7rfkr8s85fb5f43rwyqvf"))))
+ "0qjips9f6fsvkyd7wj3a4gzaqknn2q4kkb19957pl86im56pna0k"))))
(build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-lock-api" ,rust-lock-api-0.4))))
(home-page "https://github.com/mvdnes/spin-rs")
(synopsis "Synchronization primitives based on spinning")
(description "This crate provides synchronization primitives based on
@@ -44858,6 +44861,21 @@ spinning. They may contain data, are usable without @code{std},and static
initializers are available.")
(license license:expat)))

+(define-public rust-spin-0.5
+ (package
+ (inherit rust-spin-0.7)
+ (name "rust-spin")
+ (version "0.5.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "spin" version))
+ (file-name (string-append name "-" version ".crate"))
+ (sha256
+ (base32
+ "0b84m6dbzrwf2kxylnw82d3dr8w06av7rfkr8s85fb5f43rwyqvf"))))
+ (arguments '(#:cargo-inputs ()))))
+
(define-public rust-spin-0.4
(package
(inherit rust-spin-0.5)
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 05/33] gnu: rust-tiny-http: Update to 0.8.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-5-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-tiny-http-0.8): New variable.
(rust-tiny-http-0.6): Inherit from rust-tiny-http-0.8.
---
gnu/packages/crates-io.scm | 39 ++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)

Toggle diff (58 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index de1b581cbd..07d0a7594e 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -49152,8 +49152,39 @@ closures after a delay or at a given timestamp.")
manipulation in Rust.")
(license license:expat)))

-(define-public rust-tiny-http-0.6
+(define-public rust-tiny-http-0.8
(package
+ (name "rust-tiny-http")
+ (version "0.8.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "tiny_http" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0fcdwpb2ghk671qjjrk6048hs3yp7f681hxpr68gamk00181prcw"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-ascii" ,rust-ascii-1)
+ ("rust-chrono" ,rust-chrono-0.4)
+ ("rust-chunked-transfer" ,rust-chunked-transfer-1)
+ ("rust-log" ,rust-log-0.4)
+ ("rust-openssl" ,rust-openssl-0.10)
+ ("rust-url" ,rust-url-2))
+ #:cargo-development-inputs
+ (("rust-fdlimit" ,rust-fdlimit-0.1)
+ ("rust-rustc-serialize" ,rust-rustc-serialize-0.3)
+ ("rust-sha1" ,rust-sha1-0.6))))
+ (home-page "https://github.com/tiny-http/tiny-http")
+ (synopsis "Low level HTTP server library")
+ (description "This package provides a low level HTTP server library.")
+ (license license:asl2.0)))
+
+(define-public rust-tiny-http-0.6
+ (package (inherit rust-tiny-http-0.8)
(name "rust-tiny-http")
(version "0.6.2")
(source
@@ -49172,11 +49203,7 @@ manipulation in Rust.")
("rust-chunked-transfer" ,rust-chunked-transfer-0.3)
("rust-log" ,rust-log-0.4)
("rust-openssl" ,rust-openssl-0.10)
- ("rust-url" ,rust-url-1))))
- (home-page "https://github.com/tiny-http/tiny-http")
- (synopsis "Low level HTTP server library")
- (description "This package provides a low level HTTP server library.")
- (license license:asl2.0)))
+ ("rust-url" ,rust-url-1))))))

(define-public rust-tiny-keccak-2
(package
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 08/33] gnu: Add tree-sitter-cli.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-8-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-cli): New variable.
---
gnu/packages/tree-sitter.scm | 61 +++++++++++++++++++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)

Toggle diff (79 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index e6e66cd447..d8d4a305da 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -18,10 +18,13 @@

(define-module (gnu packages tree-sitter)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system cargo)
#:use-module (guix build-system gnu)
#:use-module (guix git-download)
#:use-module (guix packages)
- #:use-module (guix utils))
+ #:use-module (guix utils)
+ #:use-module (gnu packages crates-graphics)
+ #:use-module (gnu packages crates-io))

(define-public tree-sitter
(package
@@ -71,3 +74,59 @@ can be embedded in any application.

This package includes the @code{libtree-sitter} runtime library.")
(license license:expat)))
+
+(define-public tree-sitter-cli
+ (package (inherit tree-sitter)
+ (name "tree-sitter-cli")
+ (build-system cargo-build-system)
+ (arguments
+ `(;; Running test requires downloading fixtures, see the
+ ;; script/fetch-fixtures script.
+ #:tests? #f
+ ;; FIXME: Installing the sources for the tree-sitter Rust bindings
+ ;; doesn't work out of the box due to tree-sitter having multiple
+ ;; Rust packages in the same repository (bindings and CLI).
+ #:install-source? #f
+ #:cargo-inputs
+ (("rust-ansi-term" ,rust-ansi-term-0.12)
+ ("rust-atty" ,rust-atty-0.2)
+ ("rust-clap" ,rust-clap-2)
+ ("rust-difference" ,rust-difference-2)
+ ("rust-dirs" ,rust-dirs-3)
+ ("rust-html-escape" ,rust-html-escape-0.2)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-smallbitvec" ,rust-smallbitvec-2)
+ ("rust-spin" ,rust-spin-0.7)
+ ("rust-tiny-http" ,rust-tiny-http-0.8)
+ ("rust-walkdir" ,rust-walkdir-2)
+ ("rust-webbrowser" ,rust-webbrowser-0.5)
+ ("rust-which" ,rust-which-4))
+ #: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)))))))
+ (synopsis "Incremental parsing system for programming tools")
+ (description "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @command{tree-sitter} command-line tool.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 09/33] gnu: node: Patch /usr/bin/env in node-gyp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-9-pierre.langlois@gmx.com
* gnu/packages/node.scm (node)[arguments]: Fix /usr/bin/env shebang in
node-gyp.js.
(node-lts)[arguments]: Ditto.
---
gnu/packages/node.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

Toggle diff (37 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 36c45e9c7a..530c04bc68 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -6,7 +6,7 @@
;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018, 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
-;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020, 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;;
@@ -120,6 +120,11 @@
(("'/usr/bin/env'")
(string-append "'" (which "env") "'")))

+ ;; Fix /usr/bin/env shebang in node-gyp.
+ (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
+ (("#!/usr/bin/env")
+ (string-append "#!" (assoc-ref inputs "coreutils") "/bin/env")))
+
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
@@ -661,6 +666,11 @@ source files.")
(("'/usr/bin/env'")
(string-append "'" (which "env") "'")))

+ ;; Fix /usr/bin/env shebang in node-gyp.
+ (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
+ (("#!/usr/bin/env")
+ (string-append "#!" (assoc-ref inputs "coreutils") "/bin/env")))
+
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 11/33] gnu: Add node-nan.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-11-pierre.langlois@gmx.com
---
gnu/packages/node-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (48 lines)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index cbb68f77d6..eb4b59d1ab 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 Noisytoot <noisytoot@disroot.org>
;;; Copyright © 2021 Charles <charles.b.jackson@protonmail.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -171,6 +172,35 @@ user-land JavaScript.")
random number generator.")
(license license:bsd-3)))

+(define-public node-nan
+ (package
+ (name "node-nan")
+ (version "2.15.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/nan")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "18xslh9va5ld872scrp5y4251ax9s3c6qh0lnl1200lpzbsxy7yd"))))
+ (build-system node-build-system)
+ (arguments
+ '(#:tests? #f ; FIXME: tests depend on node-tap
+ #:phases
+ (modify-phases %standard-phases
+ ;; The default configure phase fails due to tap being missing, as we do
+ ;; not have tap packaged yet. It is used only for tests. This package
+ ;; still works as a dependency of node-glob and node-inflight.
+ (delete 'configure))))
+ (home-page "https://github.com/nodejs/nan")
+ (synopsis "Native Abstractions for Node.js")
+ (description "This package provides header files filled with macros and
+utilities for making add-on development for Node.js easier across versions.")
+ (license license:bsd-3)))
+
(define-public node-oop
;; No releases, last commit was February 2013.
(let ((commit "f9d87cda0958886955c14a0a716e57021ed295dc")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 10/33] guix: node-build-system: Support compiling addons with node-gyp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-10-pierre.langlois@gmx.com
* gnu/packages/node.scm (node-headers): New function.
* guix/build-system/node.scm (python): New function.
(node-headers): New function.
(lower): Add node-headers and python to build inputs.
* guix/build/node-build-system.scm (configure-gyp): New function.
(%standard-phases): Add 'configure-gyp after 'configure.
---
gnu/packages/node.scm | 19 ++++++++++++++++++-
guix/build-system/node.scm | 16 ++++++++++++++++
guix/build/node-build-system.scm | 15 +++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)

Toggle diff (111 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 530c04bc68..a6dab75309 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -48,7 +48,24 @@
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages tls)
- #:use-module (gnu packages web))
+ #:use-module (gnu packages web)
+ #:use-module (ice-9 match)
+ #:export (node-headers))
+
+(define (node-headers node)
+ "Return an <origin> object for a tarball with headers for the given node
+package version."
+ (let* ((version (package-version node))
+ (hash (match version
+ ("10.24.0"
+ "0h37zjwcpxjdqcxqjfj5zp1n5zjxaa0g8lsy83955afg5cca8p0n")
+ ("14.16.0"
+ "1vpdgq7kcw1a0w90lpvbvxbrc0n3pwjrs3sm42pjj7560clvji2b"))))
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://nodejs.org/dist/v" version
+ "/node-v" version "-headers.tar.gz"))
+ (sha256 (base32 hash)))))

(define-public node
(package
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 98f63f87ef..7828582a9a 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -41,6 +42,19 @@
(let ((node (resolve-interface '(gnu packages node))))
(module-ref node 'node-lts)))

+(define (python)
+ "Return the python package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages python))))
+ (module-ref module 'python-wrapper)))
+
+(define (node-headers node)
+ "Return a tarball with headers for the given node, needed for packages that
+need to build native bindings using node-gyp."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages node))))
+ ((module-ref module 'node-headers) node)))
+
(define* (lower name
#:key source inputs native-inputs outputs system target
(node (default-node))
@@ -62,6 +76,8 @@
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ("node-headers" ,(node-headers node))
+ ("python" ,(python))
,@native-inputs))
(outputs outputs)
(build node-build)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..2993c49b2b 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -101,6 +102,19 @@
(invoke npm "--offline" "--ignore-scripts" "install")
#t))

+(define* (configure-gyp #:key inputs #:allow-other-keys)
+ "Run 'node-gyp configure' if we see a 'binding.gyp' file.
+
+By default, 'node-gyp' will try to download node headers from the internet, we
+prevent this with the '--tarball' flag."
+ (let ((node-gyp (string-append (assoc-ref inputs "node")
+ "/lib/node_modules/npm/node_modules/node-gyp"
+ "/bin/node-gyp.js")))
+ (if (file-exists? "binding.gyp")
+ (invoke node-gyp "--tarball" (assoc-ref inputs "node-headers")
+ "configure"))
+ #t))
+
(define* (build #:key inputs #:allow-other-keys)
(let ((package-meta (call-with-input-file "package.json" read-json)))
(if (and=> (assoc-ref package-meta "scripts")
@@ -147,6 +161,7 @@
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
(replace 'configure configure)
+ (add-after 'configure 'configure-gyp configure-gyp)
(replace 'build build)
(replace 'check check)
(add-before 'install 'repack repack)
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 13/33] gnu: Add tree-sitter-cpp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-13-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-cpp): New variable.
---
gnu/packages/tree-sitter.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (32 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index bc04a4a5a7..07bdb54627 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -191,3 +191,27 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a C grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-cpp
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-cpp")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-cpp")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "08ywv6n80sa541rr08bqz4zyg7byvjcabp68lvxmcahjk8xzcgwk"))))
+ (native-inputs
+ `(("tree-sitter-cli" ,tree-sitter-cli)
+ ("tree-sitter-c" ,tree-sitter-c)
+ ("node-nan" ,node-nan)))
+ (home-page "https://github.com/tree-sitter/tree-sitter-cpp")
+ (synopsis "Tree-sitter C++ grammar")
+ (description
+ "This package provides a C++ grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 14/33] gnu: Add tree-sitter-bash.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-14-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-bash): New variable.
---
gnu/packages/tree-sitter.scm | 41 ++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

Toggle diff (49 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 07bdb54627..f98a7d392f 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -215,3 +215,44 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a C++ grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-bash
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-bash")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-bash")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "18c030bb65r50i6z37iy7jb9z9i8i36y7b08dbc9bchdifqsijs5"))))
+ (native-inputs
+ `(("tree-sitter-cli" ,tree-sitter-cli)
+ ("node-nan" ,node-nan)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The `prebuild' dependency is a way to intercept the build step
+ ;; and download a prebuilt binary instead. If we remove it then the
+ ;; buid system falls back to building from source.
+ (add-after 'unpack 'remove-prebuild-dependency
+ (lambda _
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (use-modules ((guix build json)))
+ (let ((package-meta (read-json in)))
+ (assoc-remove! (assoc-ref package-meta "dependencies")
+ "prebuild-install")
+ (assoc-remove! (assoc-ref package-meta "devDependencies")
+ "prebuild")
+ (write-json package-meta out))))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-bash")
+ (synopsis "Tree-sitter Bash grammar")
+ (description
+ "This package provides a Bash grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 15/33] gnu: Add tree-sitter-css.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-15-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-css): New variable.
---
gnu/packages/tree-sitter.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index f98a7d392f..592a61ed25 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -256,3 +256,23 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a Bash grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-css
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-css")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-css")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "014jrlgi7zfza9g38hsr4vlbi8964i5p7iglaih6qmzaiml7bja2"))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-css")
+ (synopsis "Tree-sitter CSS grammar")
+ (description
+ "This package provides a CSS grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 16/33] gnu: Add tree-sitter-go.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-16-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-go): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 592a61ed25..5cb3a0e76b 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -276,3 +276,32 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a CSS grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-go
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-go")
+ (version "0.19.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-go")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0nxs47vd2fc2fr0qlxq496y852rwg39flhg334s7dlyq7d3lcx4x"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-go")
+ (synopsis "Tree-sitter Go grammar")
+ (description
+ "This package provides a Golang grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 12/33] gnu: Add tree-sitter-c.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-12-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-c): New variable.
---
gnu/packages/tree-sitter.scm | 63 +++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)

Toggle diff (82 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index d8d4a305da..bc04a4a5a7 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -20,11 +20,13 @@
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (gnu packages crates-graphics)
- #:use-module (gnu packages crates-io))
+ #:use-module (gnu packages crates-io)
+ #:use-module (gnu packages node-xyz))

(define-public tree-sitter
(package
@@ -130,3 +132,62 @@ can be embedded in any application.

This package includes the @command{tree-sitter} command-line tool.")
(license license:expat)))
+
+(define-public tree-sitter-c
+ (package
+ (name "tree-sitter-c")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-c")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1diys8yigvhm4ppbmp3a473yxjg2d5lk11y0ay7qprcz7233lakv"))))
+ (build-system node-build-system)
+ (native-inputs
+ `(("tree-sitter-cli" ,tree-sitter-cli)
+ ("node-nan" ,node-nan)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ ;; tree-sitter-cli is listed as a Node.js dependency, however the
+ ;; node tree-sitter-cli package is just a wrapper which downloads a
+ ;; tree-sitter binary, see
+ ;; https://github.com/tree-sitter/tree-sitter/tree/master/cli/npm
+ ;; Instead we remove it as a dependency so that we can use our own
+ ;; tree-sitter package.
+ (add-after 'unpack 'fix-configure
+ (lambda _
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (use-modules ((guix build json)))
+ (let ((package-meta (read-json in)))
+ (assoc-remove! (assoc-ref package-meta "devDependencies")
+ "tree-sitter-cli")
+ (write-json package-meta out))))))
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC" ,(cc-for-target))))
+ (add-before 'build 'make-files-writable
+ (lambda _
+ (for-each make-file-writable (find-files "src" ".*"))))
+ (add-after 'install 'install-native-lib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out")
+ "/lib/tree-sitter")))
+ ;; Invoking `tree-sitter test' loads the grammar which
+ ;; compiles it to a .so binary that we install.
+ (invoke "tree-sitter" "test")
+ (mkdir-p lib)
+ (copy-recursively (string-append (getenv "HOME")
+ "/.tree-sitter/bin")
+ lib)))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-c")
+ (synopsis "Tree-sitter C grammar")
+ (description
+ "This package provides a C grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 17/33] gnu: Add tree-sitter-html.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-17-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-html): New variable.
---
gnu/packages/tree-sitter.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 5cb3a0e76b..e2a0757e30 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -305,3 +305,23 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a Golang grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-html
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-html")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-html")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1hg7vbcy7bir6b8x11v0a4x0glvqnsqc3i2ixiarbxmycbgl3axy"))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-html")
+ (synopsis "Tree-sitter HTML grammar")
+ (description
+ "This package provides a HTML grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 18/33] gnu: Add tree-sitter-java.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-18-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-java): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index e2a0757e30..174f0923f8 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -325,3 +325,32 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a HTML grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-java
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-java")
+ (version "0.19.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-java")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "07zw9ygb45hnvlx9qlz7rlz8hc3byjy03d24v72i5iyhpiiwlhvl"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-java")
+ (synopsis "Tree-sitter Java grammar")
+ (description
+ "This package provides a Java grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 19/33] gnu: Add tree-sitter-javascript.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-19-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-javascript): New variable.
---
gnu/packages/tree-sitter.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (38 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 174f0923f8..2be6b15cb0 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -354,3 +354,33 @@ This package includes the @command{tree-sitter} command-line tool.")
(description
"This package provides a Java grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-javascript
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-javascript")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-javascript")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "063va0s727yzhy1cz04fipzwwbq4af6fhgka6g970hk9yf7ggmnj"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-javascript")
+ (synopsis "Tree-sitter Javascript grammar")
+ (description
+ "This package provides a Javascript grammar for the Tree-sitter
+library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 20/33] gnu: Add tree-sitter-json.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-20-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-json): New variable.
---
gnu/packages/tree-sitter.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 2be6b15cb0..74249b2aca 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -384,3 +384,23 @@ This package includes the @command{tree-sitter} command-line tool.")
"This package provides a Javascript grammar for the Tree-sitter
library.")
(license license:expat)))
+
+(define-public tree-sitter-json
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-json")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-json")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "06pjh31bv9ja9hlnykk257a6zh8bsxg2fqa54al7qk1r4n9ksnff"))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-json")
+ (synopsis "Tree-sitter JSON grammar")
+ (description
+ "This package provides a JSON grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 27/33] gnu: Add rust-tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-27-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (rust-tree-sitter): New variable.
---
gnu/packages/tree-sitter.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 001322dd84..3357fce4a5 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -21,6 +21,7 @@
#:use-module (guix build-system cargo)
#:use-module (guix build-system gnu)
#:use-module (guix build-system node)
+ #:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
@@ -134,6 +135,32 @@ can be embedded in any application.
This package includes the @command{tree-sitter} command-line tool.")
(license license:expat)))

+(define-public rust-tree-sitter-0.19
+ (package
+ (name "rust-tree-sitter")
+ (version "0.19.5")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "tree-sitter" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1h6adq5kqf4izzsklch5lfxx2aisxga463zz7w44rgwnck16wwmd"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:tests? #f ;; Running tests misinterprets comments as doc-tests.
+ #:cargo-inputs
+ (("rust-cc" ,rust-cc-1)
+ ("rust-lazy-static" ,rust-lazy-static-1)
+ ("rust-regex" ,rust-regex-1)
+ ("rust-spin" ,rust-spin-0.7))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Rust bindings to the Tree-sitter parsing library")
+ (description "This package provides Rust bindings to the Tree-sitter
+parsing library.")
+ (license license:expat)))
+
(define-public tree-sitter-c
(package
(name "tree-sitter-c")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 07/33] gnu: Add tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-7-pierre.langlois@gmx.com
* gnu/package/tree-sitter.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Register it.
---
gnu/local.mk | 1 +
gnu/packages/tree-sitter.scm | 73 ++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100644 gnu/packages/tree-sitter.scm

Toggle diff (91 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index a0da1a96d8..0315106c30 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -559,6 +559,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/tls.scm \
%D%/packages/tmux.scm \
%D%/packages/tor.scm \
+ %D%/packages/tree-sitter.scm \
%D%/packages/tv.scm \
%D%/packages/uglifyjs.scm \
%D%/packages/uml.scm \
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
new file mode 100644
index 0000000000..e6e66cd447
--- /dev/null
+++ b/gnu/packages/tree-sitter.scm
@@ -0,0 +1,73 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages tree-sitter)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix git-download)
+ #:use-module (guix packages)
+ #:use-module (guix utils))
+
+(define-public tree-sitter
+ (package
+ (name "tree-sitter")
+ (version "0.19.5")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1qmb0sva28zv6r3c3j7xs9pc8bpwwhkb9vxxndw2zbdn9wkvmbmn"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ;; No check target.
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC" ,(cc-for-target))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (lib (string-append out "/lib")))
+ (setenv "PREFIX" out)
+ (invoke "make" "install")))))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Incremental parsing system for programming tools")
+ (description "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @code{libtree-sitter} runtime library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 28/33] gnu: rust-emacs-module: Update to 0.16.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-28-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-module-0.16): New variable.
(rust-emacs-module-0.10): Inherit from rust-emacs-module-0.10.
---
gnu/packages/crates-io.scm | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index f769a8e9a5..e4892d5852 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -14697,10 +14697,10 @@ Emacs' support for dynamic modules.")
(description "This package provides proc macros for Emacs modules.")
(license license:bsd-3)))

-(define-public rust-emacs-module-0.10
+(define-public rust-emacs-module-0.16
(package
(name "rust-emacs-module")
- (version "0.10.0")
+ (version "0.16.2")
(source
(origin
(method url-fetch)
@@ -14709,11 +14709,11 @@ Emacs' support for dynamic modules.")
(string-append name "-" version ".tar.gz"))
(sha256
(base32
- "1gf9lz735xbkyir53dyv362drfx3nin5an5cx39kd8q8kjjwix5g"))))
+ "0s8qrh0ggjmqr04zkcf7s4ijmpd44rjcag78npnq64jv10lxvsry"))))
(build-system cargo-build-system)
(arguments
`(#:cargo-inputs
- (("rust-bindgen" ,rust-bindgen-0.48))))
+ (("rust-bindgen" ,rust-bindgen-0.56))))
(inputs
`(("clang" ,clang)))
(home-page "https://github.com/ubolonton/emacs-module-rs")
@@ -14722,6 +14722,23 @@ Emacs' support for dynamic modules.")
Emacs' support for dynamic modules.")
(license license:bsd-3)))

+(define-public rust-emacs-module-0.10
+ (package (inherit rust-emacs-module-0.16)
+ (name "rust-emacs-module")
+ (version "0.10.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs_module" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1gf9lz735xbkyir53dyv362drfx3nin5an5cx39kd8q8kjjwix5g"))))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-bindgen" ,rust-bindgen-0.48))))))
+
(define-public rust-embed-resource-1
(package
(name "rust-embed-resource")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 31/33] gnu: Add emacs-tree-sitter-core.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-31-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable.
(emacs-tree-sitter-core): New variable.
---
gnu/packages/tree-sitter.scm | 79 ++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)

Toggle diff (101 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 3357fce4a5..13f7a63acc 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -19,6 +19,7 @@
(define-module (gnu packages tree-sitter)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
+ #:use-module (guix build-system emacs)
#:use-module (guix build-system gnu)
#:use-module (guix build-system node)
#:use-module (guix download)
@@ -28,6 +29,7 @@
#:use-module (gnu packages algebra)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages crates-io)
+ #:use-module (gnu packages llvm)
#:use-module (gnu packages node-xyz))

(define-public tree-sitter
@@ -603,3 +605,80 @@ library.")
"This package provides Typescript and TSX grammars for the Tree-sitter
library.")
(license license:expat)))
+
+;; Local package definition solely for building the native emacs module
+;; written in Rust.
+(define tree-sitter-emacs-module
+ (package
+ (name "tree-sitter-emacs-module")
+ (version "0.15.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "15y0wjnck8rbfhl0xrl71ci7clbcp11lhqil5l8ykprsdjv0c2as"))))
+ (build-system cargo-build-system)
+ (inputs
+ `(("clang" ,clang)))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-emacs" ,rust-emacs-0.17)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-tree-sitter" ,rust-tree-sitter-0.19))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'delete-cargo.lock
+ (lambda _ (delete-file "Cargo.lock")))
+ (add-after 'delete-cargo.lock 'do-not-fetch-from-github
+ (lambda _
+ (substitute* "Cargo.toml"
+ (("\\[patch.*") "")
+ (("git = .*") ""))))
+ (add-after 'do-not-fetch-from-github 'chdir
+ (lambda _ (chdir "core")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
+ (install-file "../target/release/libtsc_dyn.so" lib)))))))
+ (home-page #f)
+ (synopsis #f)
+ (description #f)
+ (license license:expat)))
+
+(define-public emacs-tree-sitter-core
+ (package
+ (name "emacs-tree-sitter-core")
+ (version (package-version tree-sitter-emacs-module))
+ (source (package-source tree-sitter-emacs-module))
+ (build-system emacs-build-system)
+ (native-inputs
+ `(("tree-sitter-emacs-module" ,tree-sitter-emacs-module)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "core")))
+ (add-after 'install 'install-module
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out")))
+ (module (string-append (assoc-ref inputs "tree-sitter-emacs-module")
+ "/lib/libtsc_dyn.so")))
+ ;; Writing "LOCAL" in this file prevents the package from
+ ;; trying to download the module from the internet.
+ (call-with-output-file (string-append elpa "/DYN-VERSION")
+ (lambda (port) (display "LOCAL" port)))
+ (substitute* "tsc-dyn-get.el"
+ (("defcustom tsc-dyn-dir tsc--dir")
+ (string-append "defcustom tsc-dyn-dir \"" elpa "\"")))
+ (copy-file module (string-append elpa "/tsc-dyn.so"))))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp, core library")
+ (description "This package provides core APIs of the Emacs binding for
+Tree-sitter, an incremental parsing system.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 23/33] gnu: Add tree-sitter-python.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-23-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-python): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index d717bbf7b0..ae8bfcd9ff 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -462,3 +462,32 @@ library.")
(description
"This package provides a PHP grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-python
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-python")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-python")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "04b85qxqs64x6nhbpcgrzkbilxaiwvr9yd3h065rynv7rsdg0hii"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-python")
+ (synopsis "Tree-sitter Python grammar")
+ (description
+ "This package provides a Python grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 21/33] gnu: Add tree-sitter-julia.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-21-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-julia): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 74249b2aca..36831b00b6 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -404,3 +404,32 @@ library.")
(description
"This package provides a JSON grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-julia
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-julia")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-julia")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1pbnmvhy2gq4vg1b0sjzmjm4s2gsgdjh7h01yj8qrrqbcl29c463"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-julia")
+ (synopsis "Tree-sitter Julia grammar")
+ (description
+ "This package provides a Julia grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 24/33] gnu: Add tree-sitter-rust.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-24-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-rust): New variable.
---
gnu/packages/tree-sitter.scm | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

Toggle diff (40 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index ae8bfcd9ff..8456a15607 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -24,6 +24,7 @@
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (gnu packages algebra)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages node-xyz))
@@ -491,3 +492,27 @@ library.")
(description
"This package provides a Python grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-rust
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-rust")
+ (version "0.19.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-rust")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "118vkhv7n3sw8y9pi0987cgdcd74sjqwviijw01mhnk3bkyczi3l"))))
+ (native-inputs
+ `(("bc" ,bc)
+ ("tree-sitter-cli" ,tree-sitter-cli)
+ ("node-nan" ,node-nan)))
+ (home-page "https://github.com/tree-sitter/tree-sitter-rust")
+ (synopsis "Tree-sitter Rust grammar")
+ (description
+ "This package provides a Rust grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:45
[PATCH v2 22/33] gnu: Add tree-sitter-php.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-22-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-php): New variable.
---
gnu/packages/tree-sitter.scm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 36831b00b6..d717bbf7b0 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -433,3 +433,32 @@ library.")
(description
"This package provides a Julia grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-php
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-php")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-php")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "17cmybgpprw7w9d2v7lmc6zmr90d70g0jqq279gzg0mpwfzla53s"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-php")
+ (synopsis "Tree-sitter PHP grammar")
+ (description
+ "This package provides a PHP grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 25/33] gnu: Add tree-sitter-typescript.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-25-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-typescript): New variable.
---
gnu/packages/tree-sitter.scm | 60 ++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)

Toggle diff (68 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 8456a15607..001322dd84 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -516,3 +516,63 @@ library.")
(description
"This package provides a Rust grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-typescript
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-typescript")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-typescript")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "01pkmwwmbv6kxda0n6g4cfg72ldmpi9gmp11a5gygn472vhrh2xw"))))
+ (native-inputs
+ `(("tree-sitter-cli" ,tree-sitter-cli)
+ ("tree-sitter-javascript" ,tree-sitter-javascript)
+ ("node-nan" ,node-nan)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))
+ (add-after 'build 'build-gyp
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((node (assoc-ref inputs "node")))
+ (invoke (string-append node "/lib/node_modules/npm/node_modules"
+ "/node-gyp/bin/node-gyp.js")
+ "build"))))
+ (replace 'make-files-writable
+ (lambda _
+ (for-each make-file-writable
+ (find-files "typescript" ".*"))
+ (for-each make-file-writable
+ (find-files "tsx" ".*"))))
+ (replace 'install-native-lib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out")
+ "/lib/tree-sitter")))
+ ;; Invoking `tree-sitter test' loads the grammar which
+ ;; compiles it to a .so binary that we install.
+ (with-directory-excursion "typescript"
+ (invoke "tree-sitter" "test"))
+ (with-directory-excursion "tsx"
+ (invoke "tree-sitter" "test"))
+ (mkdir-p lib)
+ (copy-recursively (string-append (getenv "HOME")
+ "/.tree-sitter/bin")
+ lib))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-typescript")
+ (synopsis "Tree-sitter Typescript grammar")
+ (description
+ "This package provides Typescript and TSX grammars for the Tree-sitter
+library.")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 26/33] gnu: Add rust-bindgen@0.56.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-26-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-bindgen-0.56): New variable.
---
gnu/packages/crates-io.scm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)

Toggle diff (48 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 476d35c241..f769a8e9a5 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -4541,6 +4541,43 @@ bindings to C and C++ libraries.")
("rust-shlex" ,rust-shlex-0.1)
("rust-which" ,rust-which-3))))))

+(define-public rust-bindgen-0.56
+ (package
+ (inherit rust-bindgen-0.57)
+ (name "rust-bindgen")
+ (version "0.56.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "bindgen" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0fajmgk2064ca1z9iq1jjkji63qwwz38z3d67kv6xdy0xgdpk8rd"))))
+ (arguments
+ `(#:skip-build? #t
+ #:cargo-inputs
+ (("rust-bitflags" ,rust-bitflags-1)
+ ("rust-cexpr" ,rust-cexpr-0.4)
+ ("rust-cfg-if" ,rust-cfg-if-0.1)
+ ("rust-clang-sys" ,rust-clang-sys-1)
+ ("rust-clap" ,rust-clap-2)
+ ("rust-env-logger" ,rust-env-logger-0.8)
+ ("rust-lazy-static" ,rust-lazy-static-1)
+ ("rust-lazycell" ,rust-lazycell-1)
+ ("rust-log" ,rust-log-0.4)
+ ("rust-peeking-take-while" ,rust-peeking-take-while-0.1)
+ ("rust-proc-macro2" ,rust-proc-macro2-1)
+ ("rust-quote" ,rust-quote-1)
+ ("rust-regex" ,rust-regex-1)
+ ("rust-rustc-hash" ,rust-rustc-hash-1)
+ ("rust-shlex" ,rust-shlex-0.1)
+ ("rust-which" ,rust-which-3))
+ #:cargo-development-inputs
+ (("rust-clap" ,rust-clap-2)
+ ("rust-diff" ,rust-diff-0.1)
+ ("rust-shlex" ,rust-shlex-0.1))))))
+
(define-public rust-bindgen-0.55
(package
(inherit rust-bindgen-0.57)
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 29/33] gnu: rust-emacs-macros: Update to 0.17.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-29-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-macros-0.17): New variable.
(rust-emacs-macros-0.11): Inherit from rust-emacs-macros-0.17.
---
gnu/packages/crates-io.scm | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index e4892d5852..d7375d7e56 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -14673,8 +14673,31 @@ signing, and verification in pure Rust.")
Emacs' support for dynamic modules.")
(license license:bsd-3)))

-(define-public rust-emacs-macros-0.11
+(define-public rust-emacs-macros-0.17
(package
+ (name "rust-emacs-macros")
+ (version "0.17.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs-macros" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0qg1dcn5acbirq617qq2fgg9adswif2dnr292s3qnq62wzgnyrb9"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-darling" ,rust-darling-0.10)
+ ("rust-quote" ,rust-quote-1)
+ ("rust-syn" ,rust-syn-1))))
+ (home-page "https://github.com/ubolonton/emacs-module-rs")
+ (synopsis "Proc macros for Emacs modules")
+ (description "This package provides proc macros for Emacs modules.")
+ (license license:bsd-3)))
+
+(define-public rust-emacs-macros-0.11
+ (package (inherit rust-emacs-macros-0.17)
(name "rust-emacs-macros")
(version "0.11.0")
(source
@@ -14686,16 +14709,11 @@ Emacs' support for dynamic modules.")
(sha256
(base32
"0390y8vafxdi334hhgrzvcqjq3n5ckcmvilqcfp8vajjq8irrly6"))))
- (build-system cargo-build-system)
(arguments
`(#:cargo-inputs
(("rust-darling" ,rust-darling-0.9)
("rust-quote" ,rust-quote-0.6)
- ("rust-syn" ,rust-syn-0.15))))
- (home-page "https://github.com/ubolonton/emacs-module-rs")
- (synopsis "Proc macros for Emacs modules")
- (description "This package provides proc macros for Emacs modules.")
- (license license:bsd-3)))
+ ("rust-syn" ,rust-syn-0.15))))))

(define-public rust-emacs-module-0.16
(package
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 32/33] gnu: Add emacs-tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-32-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (emacs-tree-sitter): New variable.
---
gnu/packages/tree-sitter.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 13f7a63acc..0454d75ad4 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -682,3 +682,30 @@ library.")
(description "This package provides core APIs of the Emacs binding for
Tree-sitter, an incremental parsing system.")
(license license:expat)))
+
+(define-public emacs-tree-sitter
+ (package
+ (name "emacs-tree-sitter")
+ (version (package-version emacs-tree-sitter-core))
+ (source (package-source emacs-tree-sitter-core))
+ (build-system emacs-build-system)
+ (propagated-inputs
+ `(("emacs-tree-sitter-core" ,emacs-tree-sitter-core)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "lisp"))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp")
+ (description "This package provides Emacs bindings for Tree-sitter, an
+incremental parsing library. It aims to be the foundation for a new breed of
+Emacs packages that understand code structurally. For example:
+
+@enumerate
+@item Faster, fine-grained code highlighting.
+@item More flexible code folding.
+@item Structural editing (like Paredit, or even better) for non-Lisp code.
+@item More informative indexing for imenu.
+@end enumerate")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 33/33] gnu: Add emacs-tree-sitter-langs.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-33-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (emacs-tree-sitter-langs): New variable.
---
gnu/packages/tree-sitter.scm | 80 ++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)

Toggle diff (88 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 0454d75ad4..6bb52b68ac 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -709,3 +709,83 @@ Emacs packages that understand code structurally. For example:
@item More informative indexing for imenu.
@end enumerate")
(license license:expat)))
+
+(define-public emacs-tree-sitter-langs
+ (package
+ (name "emacs-tree-sitter-langs")
+ (version "0.10.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/tree-sitter-langs")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0fa0xi8sky5h3rscnvcci9djdi71qj30vivzzvx7w8pqkmsy1vq7"))))
+ (build-system emacs-build-system)
+ ;; FIXME: Support for some languages, such as bash, is still missing from
+ ;; the bundle.
+ (inputs
+ `(("tree-sitter-bash" ,tree-sitter-bash)
+ ("tree-sitter-c" ,tree-sitter-c)
+ ("tree-sitter-cpp" ,tree-sitter-cpp)
+ ("tree-sitter-css" ,tree-sitter-css)
+ ("tree-sitter-go" ,tree-sitter-go)
+ ("tree-sitter-html" ,tree-sitter-html)
+ ("tree-sitter-java" ,tree-sitter-java)
+ ("tree-sitter-javascript" ,tree-sitter-javascript)
+ ("tree-sitter-json" ,tree-sitter-json)
+ ("tree-sitter-julia" ,tree-sitter-julia)
+ ("tree-sitter-php" ,tree-sitter-php)
+ ("tree-sitter-python" ,tree-sitter-python)
+ ("tree-sitter-rust" ,tree-sitter-rust)
+ ("tree-sitter-typescript" ,tree-sitter-typescript)))
+ (propagated-inputs
+ `(("emacs-tree-sitter" ,emacs-tree-sitter)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'build 'fake-bundle
+ (lambda _
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file "bin/BUNDLE-VERSION"
+ (lambda (port) (display ,version port)))))
+ (add-after 'install 'install-libs
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (define (install-lib lang)
+ (let ((input (assoc-ref inputs (string-append "tree-sitter-" lang))))
+ (copy-file (string-append input "/lib/tree-sitter/" lang ".so")
+ (string-append elpa "/bin/" lang ".so"))))
+ (mkdir-p (string-append elpa "/bin"))
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file (string-append elpa "/bin/BUNDLE-VERSION")
+ (lambda (port) (display ,version port)))
+ (for-each (lambda (input)
+ (use-modules (ice-9 regex))
+ (cond
+ ((string-match "^tree-sitter-(.*)$" (car input))
+ => (lambda (m)
+ (install-lib (match:substring m 1))))))
+ inputs))))
+ (add-after 'install 'install-queries
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (copy-recursively "queries" (string-append elpa "/queries"))))))))
+ (home-page "https://ubolonton.github.io/emacs-tree-sitter/languages/")
+ (synopsis "Language support bundle for Tree-sitter")
+ (description "This package is a convenient language bundle for
+Tree-sitter. For each supported language, this package provides:
+
+@enumerate
+@item Pre-compiled grammar binaries.
+@item An optional highlights.scm file that provides highlighting patterns.
+This is mainly intended for major modes that are not aware of tree-sitter.
+@item Optional query patterns for other minor modes that provide high-level
+functionalities on top of tree-sitter, such as code folding, evil text
+objects, ...etc.
+@end enumerate")
+ (license license:expat)))
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:46
[PATCH v2 30/33] gnu: rust-emacs: Update to 0.17.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20210829104608.3103-30-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-0.17): New variable.
(rust-emacs-0.11): Inherit from rust-emacs-0.17.
---
gnu/packages/crates-io.scm | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)

Toggle diff (70 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index d7375d7e56..18538650f8 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -14642,10 +14642,10 @@ signing, and verification in pure Rust.")
@code{Right} is a general purpose sum type with two cases.")
(license (list license:expat license:asl2.0))))

-(define-public rust-emacs-0.11
+(define-public rust-emacs-0.17
(package
(name "rust-emacs")
- (version "0.11.0")
+ (version "0.17.0")
(source
(origin
(method url-fetch)
@@ -14654,16 +14654,18 @@ signing, and verification in pure Rust.")
(string-append name "-" version ".tar.gz"))
(sha256
(base32
- "1xn6nr8m3p24irlmv3i7c9n95yb10qc6aikwqv99qlmhbky5x0z7"))))
+ "02f31apvz03dr0dwn5wyirdmqkk2d635iki0kmsh291xr6dysy2q"))))
(build-system cargo-build-system)
(arguments
`(#:cargo-inputs
- (("rust-ctor" ,rust-ctor-0.1)
- ("rust-emacs-macros" ,rust-emacs-macros-0.11)
- ("rust-emacs-module" ,rust-emacs-module-0.10)
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-ctor" ,rust-ctor-0.1)
+ ("rust-emacs-macros" ,rust-emacs-macros-0.17)
+ ("rust-emacs-module" ,rust-emacs-module-0.16)
("rust-failure" ,rust-failure-0.1)
("rust-failure-derive" ,rust-failure-derive-0.1)
- ("rust-lazy-static" ,rust-lazy-static-1))))
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-thiserror" ,rust-thiserror-1))))
(inputs
`(("clang" ,clang)))
(home-page "https://github.com/ubolonton/emacs-module-rs")
@@ -14673,6 +14675,28 @@ signing, and verification in pure Rust.")
Emacs' support for dynamic modules.")
(license license:bsd-3)))

+(define-public rust-emacs-0.11
+ (package (inherit rust-emacs-0.17)
+ (name "rust-emacs")
+ (version "0.11.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1xn6nr8m3p24irlmv3i7c9n95yb10qc6aikwqv99qlmhbky5x0z7"))))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-ctor" ,rust-ctor-0.1)
+ ("rust-emacs-macros" ,rust-emacs-macros-0.11)
+ ("rust-emacs-module" ,rust-emacs-module-0.10)
+ ("rust-failure" ,rust-failure-0.1)
+ ("rust-failure-derive" ,rust-failure-derive-0.1)
+ ("rust-lazy-static" ,rust-lazy-static-1))))))
+
(define-public rust-emacs-macros-0.17
(package
(name "rust-emacs-macros")
--
2.33.0
P
P
Pierre Langlois wrote on 29 Aug 2021 12:53
Re: [PATCH v2 33/33] gnu: Add emacs-tree-sitter-langs.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
87a6l0zfll.fsf@gmx.com
Pierre Langlois <pierre.langlois@gmx.com> writes:

Toggle quote (31 lines)
> * gnu/packages/tree-sitter.scm (emacs-tree-sitter-langs): New variable.
> ---
> gnu/packages/tree-sitter.scm | 80 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 80 insertions(+)
>
> diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
> index 0454d75ad4..6bb52b68ac 100644
> --- a/gnu/packages/tree-sitter.scm
> +++ b/gnu/packages/tree-sitter.scm
> @@ -709,3 +709,83 @@ Emacs packages that understand code structurally. For example:
> @item More informative indexing for imenu.
> @end enumerate")
> (license license:expat)))
> +
> +(define-public emacs-tree-sitter-langs
> + (package
> + (name "emacs-tree-sitter-langs")
> + (version "0.10.3")
> + (source (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/emacs-tree-sitter/tree-sitter-langs")
> + (commit version)))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32
> + "0fa0xi8sky5h3rscnvcci9djdi71qj30vivzzvx7w8pqkmsy1vq7"))))
> + (build-system emacs-build-system)
> + ;; FIXME: Support for some languages, such as bash, is still missing from
> + ;; the bundle.

Whoops, I forgot to update the comment after adding support for bash,
I'll fix that locally!

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmErZ0YYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UCNEIAJ5g/QxVLsVCxc0mteI/GGH8
9JJgBK7Vm/I1YctpnEWyllBqARrPz5n1lz8S3fVTbq6ULO6jM+uf8FEIerZWz57R
ds9qK+0LzioOxCEKW5o1p0ag3uasxeJjb1B0bOK9xa7zE6dnpPRQqzl0Itz9lAPd
julUBUsMT9LjdLlZjbiLhA2W36ebocPo3DiOU4iaMbO2ajt3DD99mJ+ZNdRS//7T
gY9xNnfIxugg4r6TH/XGOAph5NVjKzcmyqIinLen8fdgUlNUxlV1xZrXGz5YoCDV
jWAzxUT10y/T6kdUgSICYRQP6X0IY/WlijGCPIFiWpX9DmrJigq9dg2gAnI+xfE=
=lgHC
-----END PGP SIGNATURE-----

P
P
Philip McGrath wrote on 23 Sep 2021 11:18
Re: [bug#49946] [PATCH 08/31] gnu: node: Patch /usr/bin/env in node-gyp.
b6be6177-c9f4-22ec-87dc-a54a06ec48cf@philipmcgrath.com
I'm interested in the node-gyp part of this, which has come up in some
other software I'm trying to package. These comments come with the
caveat that my experience with node.js and npm is fairly shallow.

On 8/10/21 2:28 PM, Maxime Devos wrote:
Toggle quote (13 lines)
> Pierre Langlois schreef op ma 09-08-2021 om 00:33 [+0100]:
>> @@ -120,6 +120,10 @@
>> (("'/usr/bin/env'")
>> (string-append "'" (which "env") "'")))
>>
>> + ;; Fix /usr/bin/env shebang in node-gyp.
>> + (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
>> + (("#!/usr/bin/env") (string-append "#!" (which "env"))))
>
> For cross-compilation, this should most likely be
> (string-append (assoc-ref inputs "coreutils") "/bin/env")
> or something like that instead. Likewise in other places.

Since the shebang line for node-gyp is specifically "#!/usr/bin/env
node", I wonder if it should use the node built by this package, rather
than a dynamic node.

More generally, I see that there are 355 directories installed under
"lib/node_modules/npm/node_modules" (which corresponds to the "deps"
path above). Most of them don't seem to be available as Guix packages
that could be depended upon by other Guix node packages. I'd guess
node-gyp may not be the only one with shebangs that ought to be patched.

On 8/8/21 6:29 PM, Pierre Langlois wrote:

> ... `node-gyp' needs

> node headers to compile against, packaged as a tarball, which it tries

> to download. Instead, we can run a `node-gyp --tarball <> configure'

> step to manually provide the tarball, which we can package separately

> for any given node version.

There is also a --nodedir option, which I found could work with
something like:

(string-append "--nodedir=" (assoc-ref inputs "node"))

That seems like it might be better, though I don't know all the
considerations for cross-compilation and such.

-Philip
P
P
Pierre Langlois wrote on 25 Sep 2021 12:24
(name . Philip McGrath)(address . philip@philipmcgrath.com)
87o88gq5p5.fsf@gmx.com
Hi Philip,

Philip McGrath <philip@philipmcgrath.com> writes:

Toggle quote (4 lines)
> I'm interested in the node-gyp part of this, which has come up in some other
> software I'm trying to package. These comments come with the caveat that my
> experience with node.js and npm is fairly shallow.

Thanks for your feedback!

Toggle quote (18 lines)
>
> On 8/10/21 2:28 PM, Maxime Devos wrote:
>> Pierre Langlois schreef op ma 09-08-2021 om 00:33 [+0100]:
>>> @@ -120,6 +120,10 @@
>>> (("'/usr/bin/env'")
>>> (string-append "'" (which "env") "'")))
>>>
>>> + ;; Fix /usr/bin/env shebang in node-gyp.
>>> + (substitute* "deps/npm/node_modules/node-gyp/bin/node-gyp.js"
>>> + (("#!/usr/bin/env") (string-append "#!" (which "env"))))
>> For cross-compilation, this should most likely be
>> (string-append (assoc-ref inputs "coreutils") "/bin/env")
>> or something like that instead. Likewise in other places.
>
> Since the shebang line for node-gyp is specifically "#!/usr/bin/env node", I
> wonder if it should use the node built by this package, rather than a dynamic
> node.

Yeah we could do that, although I generally prefer to follow whatever
the script already does, there could be a good reason for them to use
`env' no?

Toggle quote (5 lines)
> More generally, I see that there are 355 directories installed under
> "lib/node_modules/npm/node_modules" (which corresponds to the "deps"
> path above). Most of them don't seem to be available as Guix packages that could
> be depended upon by other Guix node packages.

Yeah that's tricky, ideally we should remove all the node_modules deps
and package them separately, I wonder if anybody tried to do that
already. I would suspect it to be quite a lot of work, sometimes
unbundling stops being worth and when it's hard to maintain dependencies
manually.

Hopefully we can get there one day though! I don't want to deter anybody
from trying :-), I might give it a go on a raindy day.

Toggle quote (3 lines)
> I'd guess node-gyp may not be the only one with shebangs that ought to
> be patched.

Yeah there could be others, although normally the patching phase from
the gnu build system should have taken care of most of them, hopefully
all, I'm not sure why it didn't work for /usr/bin/env though.

I would suggest we patch things as we encounter them, did you find
anymore issues when working on your package?

For instance, while working on a newer version of one of the packages in
this series, I saw we may need to patch GYP's python reference as well,
like so:

(substitute* "deps/npm/node_modules/node-gyp/gyp/gyp_main.py"
(("#!/usr/bin/env python")
(string-append "#!" (assoc-ref inputs "python") "/bin/python3")))

Only for node 14+. The reason seems to be that gyp still refers to
"python", but python2 is no longer a dependency for newer nodes. And it
seems GYP is perfectly happy with python3, and the shebang is fixed
upstream so a never node will be fine:

Maybe updating node would be better than this fix though.

Toggle quote (19 lines)
> On 8/8/21 6:29 PM, Pierre Langlois wrote:
>
>> ... `node-gyp' needs
>
>> node headers to compile against, packaged as a tarball, which it tries
>
>> to download. Instead, we can run a `node-gyp --tarball <> configure'
>
>> step to manually provide the tarball, which we can package separately
>
>> for any given node version.
>
> There is also a --nodedir option, which I found could work with something like:
>
> (string-append "--nodedir=" (assoc-ref inputs "node"))
>
> That seems like it might be better, though I don't know all the considerations
> for cross-compilation and such.

Oh that's a good idea, I didn't really like having to download the
headers separately from the main package, especially given we run
snippet on the source to remove bundled dependencies.

Trying this out this approach does work, but I needed to:

- Create a union directory with both node and libuv. The node package
only has headers for V8/node, but we also need libuv, so doing
something like this works:

(union-build node-sources
(list (assoc-ref inputs "node")
(assoc-ref inputs "libuv"))
#:create-all-directories? #t
#:log-port (%make-void-port "w"))

- For some reason, --nodedir didn't really "configure" gyp to use that
node directory, I think it's meant to be passed everytime you run
any gyp command. Instead I found that you can use and environment
variable:

(setenv "npm_config_nodedir" node-sources)

And that works for the packages in this series! That'll be much better
than before, I'll do it this way.

Thanks again for taking a look, I'll see if I can send updated patches
sometimes this weekend.

Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmFPAacYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UX4cH/iBUk2LanVkCltAcn4bCP3vo
+L+wCv7vDSWeU0D0H3VIVCutk2x+6nUcSLch8hansMGKIaDnfAzuf7o60cl7MLfh
v3JfY20Y8yFPFhRV4xPKTUmFt55cyLBkBfjDjP8hALTaON8wASSm802vMgELgMx/
TyaSWrcW8ObXr9M+721FyTKeG4qtHECunEuDJvJ1tPEo7b+MRN9I+PwkmRM1Uqh7
1DxOBg9UOL4Jt2VoDRbqO584j/+p3A+9uGzuLJ4R/Va+FPvSXuImQy//YwkHyW7r
eRd5NWFo9ch+OsfJUhORAVKGThwWWwh2bT36OgtfMXCd7S4ko/EP56eOaZ2taK8=
=rNU6
-----END PGP SIGNATURE-----

P
P
Philip McGrath wrote on 27 Sep 2021 00:02
(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
e2aec7f8-5930-367a-2cd2-b9dddc352fa3@philipmcgrath.com
Hi Pierre,

On 9/25/21 6:24 AM, Pierre Langlois wrote:
Toggle quote (8 lines)
> Philip McGrath <philip@philipmcgrath.com> writes:
>> Since the shebang line for node-gyp is specifically "#!/usr/bin/env node", I
>> wonder if it should use the node built by this package, rather than a dynamic
>> node.
>
> Yeah we could do that, although I generally prefer to follow whatever
> the script already does, there could be a good reason for them to use
> `env' no
I think it might be better to use `patch-shebang` from `(guix build
utils)` rather than `substitute*` these by hand, and it seems that
`patch-shebang` removed the indirection through `env`. My guess is most
of these cases are to accommodate the fact that `node` and `python` are
often installed to places other than `/usr/bin`.

>> I'd guess node-gyp may not be the only one with shebangs that ought to

>> be patched.

>

> Yeah there could be others, although normally the patching phase from

> the gnu build system should have taken care of most of them, hopefully

> all, I'm not sure why it didn't work for /usr/bin/env though.

>

> I would suggest we patch things as we encounter them, did you find

> anymore issues when working on your package?


Looking at `gnu-build-system`, it seems that the `'patch-shebangs` phase
only operates on files installed in the "/bin" and "/sbin"
subdirectories of the package's outputs. That restriction doesn't make
sense to me in general: for instance, what about "/libexec"? For Node
specifically, this misses a lot of stuff under "/lib/node_modules" and
"/lib/node_modules/npm/node_modules". I think I more general fix could
subsume the `'patch-npm-shebang` and `'patch-node-shebang` phases in
building Node, too.

> For instance, while working on a newer version of one of the packages in

> this series, I saw we may need to patch GYP's python reference as well,

> like so:

>

> (substitute* "deps/npm/node_modules/node-gyp/gyp/gyp_main.py"

> (("#!/usr/bin/env python")

> (string-append "#!" (assoc-ref inputs "python") "/bin/python3")))

>

> Only for node 14+. The reason seems to be that gyp still refers to

> "python", but python2 is no longer a dependency for newer nodes. And it

> seems GYP is perfectly happy with python3, and the shebang is fixed

> upstream so a never node will be fine:



I think in some places (but perhaps not enough places) Guix uses
`python-wrapper` to work around this ...

>

> Maybe updating node would be better than this fix though.

I'm not totally clear on whether the upstream fix is in 14.17.6 LTS,
but, if so, that seems great!

Toggle quote (15 lines)
>
>> More generally, I see that there are 355 directories installed under
>> "lib/node_modules/npm/node_modules" (which corresponds to the "deps"
>> path above). Most of them don't seem to be available as Guix packages that could
>> be depended upon by other Guix node packages.
>
> Yeah that's tricky, ideally we should remove all the node_modules deps
> and package them separately, I wonder if anybody tried to do that
> already. I would suspect it to be quite a lot of work, sometimes
> unbundling stops being worth and when it's hard to maintain dependencies
> manually.
>
> Hopefully we can get there one day though! I don't want to deter anybody
> from trying :-), I might give it a go on a raindy day.

Since these are developed and released with Node, and apparently we can
build them as part of the Node build process, I was thinking we could
just make packages that point to these versions we're already building.
It might be good to hear from someone who develops with node/npm, though
... I just use it to install software that I can't find packaged elsewhere.

Toggle quote (36 lines)
>
>> On 8/8/21 6:29 PM, Pierre Langlois wrote:
>>
>>> ... `node-gyp' needs
>>
>>> node headers to compile against, packaged as a tarball, which it tries
>>
>>> to download. Instead, we can run a `node-gyp --tarball <> configure'
>>
>>> step to manually provide the tarball, which we can package separately
>>
>>> for any given node version.
>>
>> There is also a --nodedir option, which I found could work with something like:
>>
>> (string-append "--nodedir=" (assoc-ref inputs "node"))
>>
>> That seems like it might be better, though I don't know all the considerations
>> for cross-compilation and such.
>
> Oh that's a good idea, I didn't really like having to download the
> headers separately from the main package, especially given we run
> snippet on the source to remove bundled dependencies.
>
> Trying this out this approach does work, but I needed to:
>
> - Create a union directory with both node and libuv. The node package
> only has headers for V8/node, but we also need libuv, so doing
> something like this works:
>
> (union-build node-sources
> (list (assoc-ref inputs "node")
> (assoc-ref inputs "libuv"))
> #:create-all-directories? #t
> #:log-port (%make-void-port "w"))

I found it worked to just add libuv as an input of packages built with
node-gyp. I hadn't tried to change `node-build-system`, but I think that
would be the place to do it.

Toggle quote (8 lines)
>
> - For some reason, --nodedir didn't really "configure" gyp to use that
> node directory, I think it's meant to be passed everytime you run
> any gyp command. Instead I found that you can use and environment
> variable:
>
> (setenv "npm_config_nodedir" node-sources)

That seems right. I believe there's a similar "npm_config_python" for
the Python executable to use.

Alternatively, I think it's possible to configure these in

Toggle quote (7 lines)
>
> And that works for the packages in this series! That'll be much better
> than before, I'll do it this way.
>
> Thanks again for taking a look, I'll see if I can send updated patches
> sometimes this weekend.

Glad it was useful!

For patching the shebangs, here's a variant of node-lts that worked for
me, though I think it would be even better to combine it with the
existing phases:

```
(define-public patched-node
(let ((node node-lts))
(package
(inherit node)
(arguments
(substitute-keyword-arguments (package-arguments node)
((#:phases standard-phases)
`(modify-phases ,standard-phases
(add-after 'patch-npm-shebang 'patch-more-shebangs
(lambda* (#:key inputs outputs #:allow-other-keys)
(define (append-map f lst)
(apply append (map f lst)))
;; from patch-shebangs
(define bin-directories
;;(match-lambda
;; ((_ . dir)
(lambda (pr)
(let ((dir (cdr pr)))
(list (string-append dir "/bin")
(string-append dir "/sbin")))))
(define output-bindirs
(append-map bin-directories outputs))
(define input-bindirs
;; Shebangs should refer to binaries of the target
system---i.e., from
;; "inputs", not from "native-inputs".
(append-map bin-directories inputs))
(define path
(append output-bindirs input-bindirs))
(with-directory-excursion
(string-append (assoc-ref outputs "out")
"/lib/node_modules/npm/node_modules")
(for-each
;;(cut patch-shebang <> path)
(lambda (file)
(patch-shebang file path))
;; from patch-generated-file-shebangs
(find-files "."
(lambda (file stat)
(and (eq? 'regular (stat:type stat))
(not (zero? (logand (stat:mode
stat) #o100)))))
#:stat lstat))))))))))))
```

-Philip
M
M
Maxime Devos wrote on 27 Sep 2021 12:11
(address . 49946@debbugs.gnu.org)
592a9a571437c4c053ceeb27ed0512deeb0667c6.camel@telenet.be
Philip McGrath schreef op zo 26-09-2021 om 18:02 [-0400]:
Toggle quote (5 lines)
> Looking at `gnu-build-system`, it seems that the `'patch-shebangs` phase
> only operates on files installed in the "/bin" and "/sbin"
> subdirectories of the package's outputs. That restriction doesn't make
> sense to me in general: for instance, what about "/libexec"?

'libexec' is included on core-updates{,-frozen}. I believe the idea of the
restriction is to avoid patching too much. E.g., "autoconf" has a file
share/autoconf/build-aux/config.guess with a #!/bin/sh shebang. It should
not be patched, otherwise tarballs created with "make dist" would include
a store path and hence be Guix-specific and architecture-specific.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVGYyRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7s12AQD9RgeUKLsp/NrdpynQ5KtLzf0d
a1QqfgnU6s2rGOREIAD/SHKNqg5x/YfmpJfybEGqoFkKoZQtpzZdNBi2pOOgOQ4=
=JNjt
-----END PGP SIGNATURE-----


P
P
Philip McGrath wrote on 29 Sep 2021 06:45
(address . 49946@debbugs.gnu.org)
ac0288a7-fdc2-e43f-40ce-c778b6a474d4@philipmcgrath.com
On 9/27/21 6:11 AM, Maxime Devos wrote:
Toggle quote (12 lines)
> Philip McGrath schreef op zo 26-09-2021 om 18:02 [-0400]:
>> Looking at `gnu-build-system`, it seems that the `'patch-shebangs` phase
>> only operates on files installed in the "/bin" and "/sbin"
>> subdirectories of the package's outputs. That restriction doesn't make
>> sense to me in general: for instance, what about "/libexec"?
>
> 'libexec' is included on core-updates{,-frozen}. I believe the idea of the
> restriction is to avoid patching too much. E.g., "autoconf" has a file
> share/autoconf/build-aux/config.guess with a #!/bin/sh shebang. It should
> not be patched, otherwise tarballs created with "make dist" would include
> a store path and hence be Guix-specific and architecture-specific.

That makes some sense. I would have thought checking that the file is
executable would catch most such cases, but, if this works for
`gnu-build-system`, great.

As I look at potentially making a patch, another thing that seems odd is
that `(gnu packages node)` exports node@10.24.0 as `node` (via
`define-public`), but node@14.16.0 as `node-lts`. Normally, if I saw
that there were packages `node` and `node-lts`, I'd assume that
`node-lts` was *older*. It's especially confusing because, at the
command line, `guix install node` refers to what in Scheme you have to
write as `node-lts`.

I wonder if it was a mistake, and should have used `define` rather than
`define-public`, since this code:

```
;; This should be the latest version of node that still builds without
;; depending on llhttp.
(define-public node-bootstrap
(hidden-package node))
```

seems to be trying to hide the older node.

It looks like `node` has only a few dependents, and it seems like at
least several of them only used it because it had the more obvious name.
The `node-build-system` uses `node-lts` as the `(default-node)`.

Would it make sense to change the names? Or just to remove the
`define-public` of `node`?

-Philip
P
P
Philip McGrath wrote on 29 Sep 2021 08:31
(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
682f2ed3-90bd-a9f8-1193-34bef399ca62@philipmcgrath.com
On 9/25/21 6:24 AM, Pierre Langlois wrote:
Toggle quote (14 lines)
> For instance, while working on a newer version of one of the packages in
> this series, I saw we may need to patch GYP's python reference as well,
> like so:
>
> (substitute* "deps/npm/node_modules/node-gyp/gyp/gyp_main.py"
> (("#!/usr/bin/env python")
> (string-append "#!" (assoc-ref inputs "python") "/bin/python3")))
>
> Only for node 14+. The reason seems to be that gyp still refers to
> "python", but python2 is no longer a dependency for newer nodes. And it
> seems GYP is perfectly happy with python3, and the shebang is fixed
> upstream so a never node will be fine:
> https://github.com/nodejs/node-gyp/pull/2355/files

I think this needs to be a `python` from `inputs` rather than
`native-inputs`, for cross-compilation, IIUC.

I tried building node 14.18.0, and it ran into other issues, but there
were still a number shebangs with `python` rather than `python3` in
various places, though I think they'd be fine with `python-wrapper`.

-Philip
P
P
Philip McGrath wrote on 1 Oct 2021 00:56
[PATCH 0/3] guix: node-build-system: Support compiling addons with node-gyp.
(address . 49946@debbugs.gnu.org)
20210930225611.2143194-1-philip@philipmcgrath.com
Hi,

I've reworked the part of the patch series dealing with node-gyp.

I'd like to find an NPM addon package to submit as part of this series, too,
basically as a test case. If I can find one that doesn't raise too many other
complications, I may send this in as a separate patch, but feel free to try it
with tree-sitter, too.

There are a few things I'm still not sure about. I haven't made
node-build-system add libuv as an implicit input, because I think some
node-gyp addons don't actually need libuv, but maybe it's common enough that
it should be done automatically.

Likewise, I haven't tried to change the issue of `node` referring to
`node-bootstrap`, but I still think it should be changed.

These patches are also on GitLab at

Improvements welcome!

-Philip


Philip McGrath (3):
gnu: node: Avoid duplicating build phases.
gnu: node: Update to 10.24.1 for bootstrapping.
guix: node-build-system: Support compiling addons with node-gyp.

gnu/packages/node.scm | 187 ++++++++++---------------------
guix/build-system/node.scm | 7 +-
guix/build/node-build-system.scm | 9 ++
3 files changed, 74 insertions(+), 129 deletions(-)

--
2.30.2
P
P
Philip McGrath wrote on 1 Oct 2021 00:56
[PATCH 1/3] gnu: node: Avoid duplicating build phases.
(address . 49946@debbugs.gnu.org)
20210930225611.2143194-2-philip@philipmcgrath.com
* gnu/packages/node.scm (node)[arguments]: Split 'patch-files phase
into 'patch-hardcoded-program-references and
'delete-problematic-tests. Adapt those phases and 'configure to work
unmodified on node-lts.
(node, node-lts)[inputs]: Use bash-minimal rather than bash.
(node-lts)[arguments]: Inherit 'patch-hardcoded-program-references,
'delete-problemating-tests, and 'configure phases from the bootstrap
node. Remove the 'patch-files phase, keeping its remaining
non-inherited work in a new 'replace-llhttp-sources phase.
---
gnu/packages/node.scm | 150 +++++++++++-------------------------------
1 file changed, 39 insertions(+), 111 deletions(-)

Toggle diff (216 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index f8ac95884c..34c2bfa9d4 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2020, 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -105,14 +106,22 @@
#:test-target "test-ci-js"
#:phases
(modify-phases %standard-phases
- (add-before 'configure 'patch-files
+ (add-before 'configure 'patch-hardcoded-program-references
(lambda* (#:key inputs #:allow-other-keys)
+
;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
- "test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
+ (substitute*
+ (let ((common
+ '("lib/child_process.js"
+ "lib/internal/v8_prof_polyfill.js"
+ "test/parallel/test-child-process-spawnsync-shell.js"
+ "test/parallel/test-stdio-closed.js"
+ "test/sequential/test-child-process-emfile.js"))
+ ;; not in bootstap node:
+ (sigxfsz "test/parallel/test-fs-write-sigxfsz.js"))
+ (if (file-exists? sigxfsz)
+ (cons sigxfsz common)
+ common))
(("'/bin/sh'")
(string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
@@ -122,18 +131,28 @@
"test/parallel/test-child-process-exec-env.js")
(("'/usr/bin/env'")
(string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
+ "/bin/env'")))))
+ (add-after 'patch-hardcoded-program-references 'delete-problematic-tests
+ (lambda* (#:key inputs #:allow-other-keys)
+ (define (delete-file-if-exists pth)
+ (when (file-exists? pth)
+ (delete-file pth)))
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
- (for-each delete-file
+ (for-each delete-file-if-exists
'("test/parallel/test-cluster-master-error.js"
"test/parallel/test-cluster-master-kill.js"
;; See also <https://github.com/nodejs/node/issues/25903>.
+ ;; (no longer exists in node-lts)
"test/sequential/test-performance.js"))
- ;; This requires a DNS resolver.
- (delete-file "test/parallel/test-dns.js")
+ ;; These require a DNS resolver.
+ (for-each delete-file-if-exists
+ '("test/parallel/test-dns.js"
+ ;; not in the bootstrap node:
+ "test/parallel/test-dns-lookupService-promises.js"))
+
;; FIXME: This test fails randomly:
;; https://github.com/nodejs/node/issues/31213
@@ -217,9 +236,13 @@
(setenv "CXX" ,(cxx-for-target))
(setenv "PKG_CONFIG" ,(pkg-config-for-target))
(apply invoke
- (string-append (assoc-ref (or native-inputs inputs)
- "python")
- "/bin/python")
+ (let ((python
+ (string-append (assoc-ref (or native-inputs inputs)
+ "python")
+ "/bin/python")))
+ (if (file-exists? python)
+ python
+ (string-append python "3")))
"configure" flags))))
(add-after 'patch-shebangs 'patch-npm-shebang
(lambda* (#:key outputs #:allow-other-keys)
@@ -256,7 +279,7 @@
(variable "NODE_PATH")
(files '("lib/node_modules")))))
(inputs
- `(("bash" ,bash)
+ `(("bash" ,bash-minimal)
("coreutils" ,coreutils)
("c-ares" ,c-ares)
("http-parser" ,http-parser)
@@ -711,103 +734,8 @@ source files.")
libuv "/lib:"
zlib "/lib"
"'],"))))))
- (replace 'configure
- ;; Node's configure script is actually a python script, so we can't
- ;; run it with bash.
- (lambda* (#:key outputs (configure-flags '()) native-inputs inputs
- #:allow-other-keys)
- (let* ((prefix (assoc-ref outputs "out"))
- (xflags ,(if (%current-target-system)
- `'("--cross-compiling"
- ,(string-append
- "--dest-cpu="
- (match (%current-target-system)
- ((? (cut string-prefix? "arm" <>))
- "arm")
- ((? (cut string-prefix? "aarch64" <>))
- "arm64")
- ((? (cut string-prefix? "i686" <>))
- "ia32")
- ((? (cut string-prefix? "x86_64" <>))
- "x64")
- ((? (cut string-prefix? "powerpc64" <>))
- "ppc64")
- (_ "unsupported"))))
- ''()))
- (flags (cons
- (string-append "--prefix=" prefix)
- (append xflags configure-flags))))
- (format #t "build directory: ~s~%" (getcwd))
- (format #t "configure flags: ~s~%" flags)
- ;; Node's configure script expects the CC environment variable to
- ;; be set.
- (setenv "CC_host" "gcc")
- (setenv "CXX_host" "g++")
- (setenv "CC" ,(cc-for-target))
- (setenv "CXX" ,(cxx-for-target))
- (setenv "PKG_CONFIG" ,(pkg-config-for-target))
- (apply invoke
- (string-append (assoc-ref (or native-inputs inputs)
- "python")
- "/bin/python3")
- "configure" flags))))
- (replace 'patch-files
+ (add-after 'delete-problematic-tests 'replace-llhttp-sources
(lambda* (#:key inputs #:allow-other-keys)
- ;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
- "test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-fs-write-sigxfsz.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
- (("'/bin/sh'")
- (string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
-
- ;; Fix hardcoded /usr/bin/env references.
- (substitute* '("test/parallel/test-child-process-default-options.js"
- "test/parallel/test-child-process-env.js"
- "test/parallel/test-child-process-exec-env.js")
- (("'/usr/bin/env'")
- (string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
-
- ;; FIXME: These tests fail in the build container, but they don't
- ;; seem to be indicative of real problems in practice.
- (for-each delete-file
- '("test/parallel/test-cluster-master-error.js"
- "test/parallel/test-cluster-master-kill.js"))
-
- ;; These require a DNS resolver.
- (for-each delete-file
- '("test/parallel/test-dns.js"
- "test/parallel/test-dns-lookupService-promises.js"))
-
- ;; FIXME: This test fails randomly:
- ;; https://github.com/nodejs/node/issues/31213
- (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
-
- ;; FIXME: These tests fail on armhf-linux:
- ;; https://github.com/nodejs/node/issues/31970
- ,@(if (target-arm32?)
- '((for-each delete-file
- '("test/parallel/test-zlib.js"
- "test/parallel/test-zlib-brotli.js"
- "test/parallel/test-zlib-brotli-flush.js"
- "test/parallel/test-zlib-brotli-from-brotli.js"
- "test/parallel/test-zlib-brotli-from-string.js"
- "test/parallel/test-zlib-convenience-methods.js"
- "test/parallel/test-zlib-random-byte-pipes.js"
- "test/parallel/test-zlib-write-after-flush.js")))
- '())
-
- ;; These tests have an expiry date: they depend on the validity of
- ;; TLS certificates that are bundled with the source. We want this
- ;; package to be reproducible forever, so remove those.
- ;; TODO: Regenerate certs instead.
- (for-each delete-file
- '("test/parallel/test-tls-passphrase.js"
- "test/parallel/test-tls-server-verify.js"))
-
;; Replace pre-generated llhttp sources
(let ((llhttp (assoc-ref inputs "llhttp")))
(copy-file (string-append llhttp "/src/llhttp.c")
@@ -834,7 +762,7 @@ source files.")
("python" ,python)
("util-linux" ,util-linux)))
(inputs
- `(("bash" ,bash)
+ `(("bash" ,bash-minimal)
("coreutils" ,coreutils)
("c-ares" ,c-ares)
("icu4c" ,icu4c-67)
--
2.30.2
P
P
Philip McGrath wrote on 1 Oct 2021 00:56
[PATCH 2/3] gnu: node: Update to 10.24.1 for bootstrapping.
(address . 49946@debbugs.gnu.org)
20210930225611.2143194-3-philip@philipmcgrath.com
* gnu/packages/node.scm (node): Update to 10.24.1.
---
gnu/packages/node.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (23 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 34c2bfa9d4..6d9c3ccc71 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -57,14 +57,14 @@
(define-public node
(package
(name "node")
- (version "10.24.0")
+ (version "10.24.1")
(source (origin
(method url-fetch)
(uri (string-append "https://nodejs.org/dist/v" version
"/node-v" version ".tar.xz"))
(sha256
(base32
- "1k1srdis23782hnd1ymgczs78x9gqhv77v0am7yb54gqcspp70hm"))
+ "032801kg24j04xmf09m0vxzlcz86sv21s24lv9l4cfv08k1c4byp"))
(modules '((guix build utils)))
(snippet
`(begin
--
2.30.2
P
P
Philip McGrath wrote on 1 Oct 2021 00:56
[PATCH 3/3] guix: node-build-system: Support compiling addons with node-gyp.
(address . 49946@debbugs.gnu.org)
20210930225611.2143194-4-philip@philipmcgrath.com
* gnu/packages/node.scm (node)[arguments]: Replace 'patch-npm-shebang
and 'patch-node-shebang with a new 'patch-nested-shebangs that also
handles node-gyp and other shebangs under "/lib/node_modules".
[inputs]: Add Python for node-gyp as "python-for-target".
(node-lts)[inputs]: Likewise.
* guix/build-system/node.scm (lower): Add optional #:python argument.
* guix/build/node-build-system.scm (set-node-gyp-paths): New
function. Sets the "npm_config_nodedir" and "npm_config_python"
environment variables.
(%standard-phases): Add 'set-node-gyp-paths after 'set-paths.

Co-authored-by: Pierre Langlois <pierre.langlois@gmx.com>
---
gnu/packages/node.scm | 33 +++++++++++++++++---------------
guix/build-system/node.scm | 7 ++++++-
guix/build/node-build-system.scm | 9 +++++++++
3 files changed, 33 insertions(+), 16 deletions(-)

Toggle diff (137 lines)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6d9c3ccc71..805a4f18fc 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -244,21 +244,22 @@
python
(string-append python "3")))
"configure" flags))))
- (add-after 'patch-shebangs 'patch-npm-shebang
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((bindir (string-append (assoc-ref outputs "out")
- "/bin"))
- (npm (string-append bindir "/npm"))
- (target (readlink npm)))
- (with-directory-excursion bindir
- (patch-shebang target (list bindir))))))
- (add-after 'install 'patch-node-shebang
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((bindir (string-append (assoc-ref outputs "out")
- "/bin"))
- (npx (readlink (string-append bindir "/npx"))))
- (with-directory-excursion bindir
- (patch-shebang npx (list bindir)))))))))
+ (add-after 'patch-shebangs 'patch-nested-shebangs
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((prefix (assoc-ref outputs "out"))
+ (path (map (lambda (dir)
+ (string-append dir "/bin"))
+ (list prefix
+ (assoc-ref inputs "python-for-target")))))
+ (with-directory-excursion (string-append prefix "/lib/node_modules")
+ (for-each
+ (lambda (file)
+ (patch-shebang file path))
+ (find-files "."
+ (lambda (file stat)
+ (and (eq? 'regular (stat:type stat))
+ (not (zero? (logand (stat:mode stat) #o100)))))
+ #:stat lstat)))))))))
(native-inputs
`(;; Runtime dependencies for binaries used as a bootstrap.
("c-ares" ,c-ares)
@@ -281,6 +282,7 @@
(inputs
`(("bash" ,bash-minimal)
("coreutils" ,coreutils)
+ ("python-for-target" ,python-wrapper) ;; for node-gyp (supports python3)
("c-ares" ,c-ares)
("http-parser" ,http-parser)
("icu4c" ,icu4c)
@@ -764,6 +766,7 @@ source files.")
(inputs
`(("bash" ,bash-minimal)
("coreutils" ,coreutils)
+ ("python-for-target" ,python-wrapper) ;; for node-gyp (supports python3)
("c-ares" ,c-ares)
("icu4c" ,icu4c-67)
("libuv" ,libuv-for-node)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 98f63f87ef..3e49e67ff6 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,6 +1,8 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -24,6 +26,7 @@
#:use-module (guix search-paths)
#:use-module (guix build-system)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system python)
#:use-module (ice-9 match)
#:export (%node-build-system-modules
node-build
@@ -44,11 +47,12 @@
(define* (lower name
#:key source inputs native-inputs outputs system target
(node (default-node))
+ (python (default-python)) ;; for node-gyp
#:allow-other-keys
#:rest arguments)
"Return a bag for NAME."
(define private-keywords
- '(#:source #:target #:node #:inputs #:native-inputs))
+ '(#:source #:target #:node #:python #:inputs #:native-inputs))
(and (not target) ;XXX: no cross-compilation
(bag
@@ -62,6 +66,7 @@
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("node" ,node)
+ ("python" ,python)
,@native-inputs))
(outputs outputs)
(build node-build)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 70a367618e..5e62eb4784 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -2,6 +2,8 @@
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
+;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -46,6 +48,12 @@
(format #t "set HOME to ~s~%" (getenv "HOME")))))))
#t)
+(define* (set-node-gyp-paths #:key inputs #:allow-other-keys)
+ "Initialize environment variables needed for building native addons."
+ (setenv "npm_config_nodedir" (assoc-ref inputs "node"))
+ (setenv "npm_config_python" (assoc-ref inputs "python"))
+ #t)
+
(define (module-name module)
(let* ((package.json (string-append module "/package.json"))
(package-meta (call-with-input-file package.json read-json)))
@@ -144,6 +152,7 @@
(define %standard-phases
(modify-phases gnu:%standard-phases
+ (add-after 'set-paths 'set-node-gyp-paths set-node-gyp-paths)
(add-after 'unpack 'set-home set-home)
(add-before 'configure 'patch-dependencies patch-dependencies)
(replace 'configure configure)
--
2.30.2
P
P
Pierre Langlois wrote on 2 Oct 2021 13:30
Re: [PATCH 0/3] guix: node-build-system: Support compiling addons with node-gyp.
(name . Philip McGrath)(address . philip@philipmcgrath.com)
87r1d3venp.fsf@gmx.com
Hi Philip,

Philip McGrath <philip@philipmcgrath.com> writes:

Toggle quote (4 lines)
> Hi,
>
> I've reworked the part of the patch series dealing with node-gyp.

Nice, thanks for working on this! I'll take a look at the patches, sorry
I've not had too much time this week yet :-).

Toggle quote (5 lines)
> I'd like to find an NPM addon package to submit as part of this series, too,
> basically as a test case. If I can find one that doesn't raise too many other
> complications, I may send this in as a separate patch, but feel free to try it
> with tree-sitter, too.

Cool, I'll give it a test with the tree-sitter series.

Toggle quote (6 lines)
>
> There are a few things I'm still not sure about. I haven't made
> node-build-system add libuv as an implicit input, because I think some
> node-gyp addons don't actually need libuv, but maybe it's common enough that
> it should be done automatically.

I see, I assumed libuv was needed for all addons. I'm thinking given
node itself heavily depends on libuv anymays, it might be nice to add it
by default in the build system, but I don't really mind either way. I'll
check if I can just add libuv in the tree-sitter packages.

Toggle quote (4 lines)
>
> Likewise, I haven't tried to change the issue of `node` referring to
> `node-bootstrap`, but I still think it should be changed.

I agree it would be good to change this. I started working on updating
node last weekend but haven't had time to work on it after that. I think
we should probably name node always as "node-<version>":

node -> node-10
node-lts -> node-14

Then keep the node and node-lts names as aliases:

(define-public node node-14) ;; The latest, but move it to node-16 later
(define-public node-lts node-14)

However, moving the node variable to node-14 is likely to cause
rebuilds, so we'll have to check that.

Anyways, here's my WIP patch in case there's anything of interest
there. Note that it still has the bug you pointed out where I'm refering
to the host python instead of the target one (thanks for pointing it
out!).

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmFYRQoYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31U/pEIAJdXHFJ7Gdbyx+axxXdEanQN
Tls8O855DPywHIgUhgGC5j6Mz6gk4/mnnEXWhbduPn+ehqvUABql9k87wF2tb+YV
sbYsBX5Xqv8GVKHW1vl1WGnCcZCJFK+x3pwrzIvsaCkN+31E2HxkSZCVCIzIk+fb
zd6yoH+nq8ZUR6QqdhA9X13FZjgm4Fq8VeDzVYrMLrvjI5RvdM3e8kN9fAkGJJpw
1WaJYAW+f1BGgQFvwUkAgUk9kUe1rbVvnt5iwGAmqCnFKwcNIvD6wYyKieVvi7U8
sGnO5V/3voK0EbLUt86b9KgQMyeFUAr27eCXULJvp5fEm8+HdLYtt4fnDcncHTI=
=AGh/
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 2 Oct 2021 13:03
Re: [PATCH 1/3] gnu: node: Avoid duplicating build phases.
(name . Philip McGrath)(address . philip@philipmcgrath.com)
87h7dzveiy.fsf@gmx.com
Hi Philip,

Philip McGrath <philip@philipmcgrath.com> writes:

Toggle quote (10 lines)
> * gnu/packages/node.scm (node)[arguments]: Split 'patch-files phase
> into 'patch-hardcoded-program-references and
> 'delete-problematic-tests. Adapt those phases and 'configure to work
> unmodified on node-lts.
> (node, node-lts)[inputs]: Use bash-minimal rather than bash.
> (node-lts)[arguments]: Inherit 'patch-hardcoded-program-references,
> 'delete-problemating-tests, and 'configure phases from the bootstrap
> node. Remove the 'patch-files phase, keeping its remaining
> non-inherited work in a new 'replace-llhttp-sources phase.

While I agree that most of the time, factoring out common code is a good
thing, I'm not sure it applies in the case of patching tests. The list
of tests is specific to a version and it's likely for each version to
need fixes. Having a common phase that describes the tests to patch for
2 versions (3 if we add node 16) is harder to maintain than three phases
IMO, even though they'll look similar indeed. Having to change commmon
code can also cause unnessecary rebuilds.

For example, I started working updating node last weekend and saw these
test changes:

- 14.16 -> 14.17: Delete test/parallel/test-https-agent-unref-socket.js,
requires networking
- 16: Extra test needs /bin/sh patched test/parallel/test-stdin-from-file-spawn.js"
A couple tests were renamed:
test/parallel/test-cluster-master-error.js -> test/parallel/test-cluster-primary-error.js
test/parallel/test-cluster-master-kill.js -> test/parallel/test-cluster-primary-kill.js

That being said, I definetely agree we should have a separate phase for
the replacement of the llhttp source, that's logically different from
patching tests, and is unlikely to change version to version.

Keeping the list of tests local to each packages allows to add node 16
while avoiding rebuilding the others, does this make sense? I could be
wrong here of course :-).

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmFYRbUYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UzrcH/i7cT2CBqJuJMKem8JeCTV0g
Z1jWeCdY1zYvmulsczCn/35nIwFi+n+YBePIoxn9pfyl6FfrMXskMavafWUSk8K2
El5QB0ITYyWQ3w7R87GIonaMxc7Yqsy/SteTe3gqLPPQCO4N3kcx4viiigLK9wGF
Q8xSWrZZlsEQat7E/z3ID0uW1AQ3Usyk+GqjEYknJQOTyutN5T1LjwMHIrICftxr
aUZ6kKxRCBLy23kprbneZykV3DHsLwvl96gGBD2XK+rKuHjvhmHl41Sqh49xms92
dVtlA7AMR/ZPrWOvvjD8oPOi610sw8HhpuNjmrv8bE0ub7Q8dL9UEqEDQkzzz4I=
=S0Pr
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 2 Oct 2021 13:49
Re: [PATCH 3/3] guix: node-build-system: Support compiling addons with node-gyp.
(name . Philip McGrath)(address . philip@philipmcgrath.com)
878rzbtyyn.fsf@gmx.com
Philip McGrath <philip@philipmcgrath.com> writes:

Toggle quote (11 lines)
> * gnu/packages/node.scm (node)[arguments]: Replace 'patch-npm-shebang
> and 'patch-node-shebang with a new 'patch-nested-shebangs that also
> handles node-gyp and other shebangs under "/lib/node_modules".
> [inputs]: Add Python for node-gyp as "python-for-target".
> (node-lts)[inputs]: Likewise.
> * guix/build-system/node.scm (lower): Add optional #:python argument.
> * guix/build/node-build-system.scm (set-node-gyp-paths): New
> function. Sets the "npm_config_nodedir" and "npm_config_python"
> environment variables.
> (%standard-phases): Add 'set-node-gyp-paths after 'set-paths.

Nice! I'll test this with the tree-sitter series. I just had one comment
inline, otherwise it looks good to me.

Do you want me to integrate it into the tree-sitter series or submit it
separately? It might make its way upstream quicker separately, in which
case I'd suggest to send it again in a new bug for more visibility.

Toggle quote (48 lines)
>
> Co-authored-by: Pierre Langlois <pierre.langlois@gmx.com>
> ---
> gnu/packages/node.scm | 33 +++++++++++++++++---------------
> guix/build-system/node.scm | 7 ++++++-
> guix/build/node-build-system.scm | 9 +++++++++
> 3 files changed, 33 insertions(+), 16 deletions(-)
>
> diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
> index 6d9c3ccc71..805a4f18fc 100644
> --- a/gnu/packages/node.scm
> +++ b/gnu/packages/node.scm
> @@ -244,21 +244,22 @@
> python
> (string-append python "3")))
> "configure" flags))))
> - (add-after 'patch-shebangs 'patch-npm-shebang
> - (lambda* (#:key outputs #:allow-other-keys)
> - (let* ((bindir (string-append (assoc-ref outputs "out")
> - "/bin"))
> - (npm (string-append bindir "/npm"))
> - (target (readlink npm)))
> - (with-directory-excursion bindir
> - (patch-shebang target (list bindir))))))
> - (add-after 'install 'patch-node-shebang
> - (lambda* (#:key outputs #:allow-other-keys)
> - (let* ((bindir (string-append (assoc-ref outputs "out")
> - "/bin"))
> - (npx (readlink (string-append bindir "/npx"))))
> - (with-directory-excursion bindir
> - (patch-shebang npx (list bindir)))))))))
> + (add-after 'patch-shebangs 'patch-nested-shebangs
> + (lambda* (#:key inputs outputs #:allow-other-keys)
> + (let* ((prefix (assoc-ref outputs "out"))
> + (path (map (lambda (dir)
> + (string-append dir "/bin"))
> + (list prefix
> + (assoc-ref inputs "python-for-target")))))
> + (with-directory-excursion (string-append prefix "/lib/node_modules")
> + (for-each
> + (lambda (file)
> + (patch-shebang file path))
> + (find-files "."
> + (lambda (file stat)
> + (and (eq? 'regular (stat:type stat))
> + (not (zero? (logand (stat:mode stat) #o100)))))
> + #:stat lstat)))))))))

Here you don't necessarily need with-directory-excursion. I see we also
have a executable-file? predicate function in (guix build utils), could
we use that? i.e:

(for-each
(lambda (file)
(patch-shebang file path))
(find-files (string-append prefix "/lib/node_modules") executable-file?))

Toggle quote (98 lines)
> (native-inputs
> `(;; Runtime dependencies for binaries used as a bootstrap.
> ("c-ares" ,c-ares)
> @@ -281,6 +282,7 @@
> (inputs
> `(("bash" ,bash-minimal)
> ("coreutils" ,coreutils)
> + ("python-for-target" ,python-wrapper) ;; for node-gyp (supports python3)
> ("c-ares" ,c-ares)
> ("http-parser" ,http-parser)
> ("icu4c" ,icu4c)
> @@ -764,6 +766,7 @@ source files.")
> (inputs
> `(("bash" ,bash-minimal)
> ("coreutils" ,coreutils)
> + ("python-for-target" ,python-wrapper) ;; for node-gyp (supports python3)
> ("c-ares" ,c-ares)
> ("icu4c" ,icu4c-67)
> ("libuv" ,libuv-for-node)
> diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
> index 98f63f87ef..3e49e67ff6 100644
> --- a/guix/build-system/node.scm
> +++ b/guix/build-system/node.scm
> @@ -1,6 +1,8 @@
> ;;; GNU Guix --- Functional package management for GNU
> ;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
> ;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
> +;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
> +;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -24,6 +26,7 @@
> #:use-module (guix search-paths)
> #:use-module (guix build-system)
> #:use-module (guix build-system gnu)
> + #:use-module (guix build-system python)
> #:use-module (ice-9 match)
> #:export (%node-build-system-modules
> node-build
> @@ -44,11 +47,12 @@
> (define* (lower name
> #:key source inputs native-inputs outputs system target
> (node (default-node))
> + (python (default-python)) ;; for node-gyp
> #:allow-other-keys
> #:rest arguments)
> "Return a bag for NAME."
> (define private-keywords
> - '(#:source #:target #:node #:inputs #:native-inputs))
> + '(#:source #:target #:node #:python #:inputs #:native-inputs))
>
> (and (not target) ;XXX: no cross-compilation
> (bag
> @@ -62,6 +66,7 @@
> ;; Keep the standard inputs of 'gnu-build-system'.
> ,@(standard-packages)))
> (build-inputs `(("node" ,node)
> + ("python" ,python)
> ,@native-inputs))
> (outputs outputs)
> (build node-build)
> diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
> index 70a367618e..5e62eb4784 100644
> --- a/guix/build/node-build-system.scm
> +++ b/guix/build/node-build-system.scm
> @@ -2,6 +2,8 @@
> ;;; Copyright © 2015 David Thompson <davet@gnu.org>
> ;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
> ;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
> +;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com>
> +;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -46,6 +48,12 @@
> (format #t "set HOME to ~s~%" (getenv "HOME")))))))
> #t)
>
> +(define* (set-node-gyp-paths #:key inputs #:allow-other-keys)
> + "Initialize environment variables needed for building native addons."
> + (setenv "npm_config_nodedir" (assoc-ref inputs "node"))
> + (setenv "npm_config_python" (assoc-ref inputs "python"))
> + #t)
> +
> (define (module-name module)
> (let* ((package.json (string-append module "/package.json"))
> (package-meta (call-with-input-file package.json read-json)))
> @@ -144,6 +152,7 @@
>
> (define %standard-phases
> (modify-phases gnu:%standard-phases
> + (add-after 'set-paths 'set-node-gyp-paths set-node-gyp-paths)
> (add-after 'unpack 'set-home set-home)
> (add-before 'configure 'patch-dependencies patch-dependencies)
> (replace 'configure configure)


The build system changes are now so nice and simple :-). I guess we
don't really need to set npm_config_python, it should be able to find
python in the PATH, but it doesn't hurt.

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmFYSsAYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UbGwIAIkzKPG7t2Zzpwiq6OpznueP
jnWlHc9SSX470xck1bwv7Gf06J84rIh523jkmiMGCiPN0vz2/KXj1FZIB6ykcJfr
lXUfBu7gEWclAa8ilV2CwJHv1Xrn5oDXUPFdLxnmnUQtPaGKC7rwqWeNeHA6/oX3
rGLCN/5PiL3sM86Fym6sealM8t8wAIRU1SwyBr2JFthoAH5O5Dvol2Mtsv1Tckzh
LvQWIg0KR+l0/sogj2YHSnhqvXemnK1icBR4hxD/5quBqpiCvH1j5Qh+1ogcKq4A
WVvabJYzc3GQoLLuJTWtNEvIRDZMite9Og75DWaopRbWQBR0Pual/aY1x5YIdRk=
=R3ZV
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 10 Feb 2022 23:39
[WIP PATCH v3 00/26] gnu: Add tree-sitter for emacs (and neovim as well?).
(address . 49946@debbugs.gnu.org)
87leyinxly.fsf@gmx.com
Hi Guix, hi Luis,

Here's a WIP V3 of my series for tree-sitter. I'm almost done with it, I
need to to another couple of passes to see if there's anything left to
cleanup.

I'm sharing it early as a WIP first, as I just noticed the other day
that Luis also contributed a patches for tree-sitter for neovim[0]. The
series I have here is quite a lot bigger though so I'm happy to rebase
it on top of yours, Luis :-). The package I had for tree-sitter looks
basically the same, I would then move it to a new file with all
tree-sitter related packages, if you're happy with that.

The other reason I'm posting this is this series, which while it only
supports emacs, actually builds grammars for some of the supported
languages, I picked a set that I think are popular, there are probably
more to add but I thought it was a good starting point. While the
grammars are originally in JSON, they are distributed as binaries it
seems so it'll be better if we can build them as part of Guix.

So I'm wondering, are these tree-sitter grammar packages also useful for
the neovim package for tree-sitter?

Anyways, see patches incoming in just a minute!

Thanks,
Pierre


Pierre Langlois (26):
gnu: Add rust-smallbitvec.
gnu: Add rust-html-escape.
gnu: Add rust-spin@0.7.
gnu: Add tree-sitter.
gnu: Add tree-sitter-cli.
gnu: Add tree-sitter-c.
gnu: Add tree-sitter-cpp.
gnu: Add tree-sitter-bash.
gnu: Add tree-sitter-css.
gnu: Add tree-sitter-go.
gnu: Add tree-sitter-html.
gnu: Add tree-sitter-java.
gnu: Add tree-sitter-javascript.
gnu: Add tree-sitter-json.
gnu: Add tree-sitter-julia.
gnu: Add tree-sitter-php.
gnu: Add tree-sitter-python.
gnu: Add tree-sitter-rust.
gnu: Add tree-sitter-typescript.
gnu: Add rust-tree-sitter-for-emacs.
gnu: rust-emacs-module: Update to 0.18.
gnu: rust-emacs-macros: Update to 0.17.
gnu: rust-emacs: Update to 0.18.
gnu: Add emacs-tree-sitter-core.
gnu: Add emacs-tree-sitter.
gnu: Add emacs-tree-sitter-langs.

gnu/local.mk | 2 +
gnu/packages/crates-io.scm | 154 +++-
.../rust-tree-sitter-text-provider-fix.patch | 98 +++
gnu/packages/tree-sitter.scm | 808 ++++++++++++++++++
4 files changed, 1044 insertions(+), 18 deletions(-)
create mode 100644 gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch
create mode 100644 gnu/packages/tree-sitter.scm

--
2.34.0
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmIFlxkYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UMf8IAK06VuxmHQYuMO49zLApSwso
ONhTcSfLy8VNGjirKEjJHaErjMbJv4kN9PUyw9YvwzGVz1aCfIBQy5p6mItzNBE0
wxY2D5GT5YummMLzXPOMfrS+eA9Og7RSp0PKGC4pg6vI+z/9CdNACpwhWQIdMV/J
lI/f2nISCzVAKusx9PiCG1zPFrUuZtCu+wyOgK53z6Pah1/hYQvEUFMx+LoNHFri
eiZHIPswLMPAbzJAghTG7v5PQ8dluUQ1C6iD1uRT2xsbDuuc7TrmKwOCLYIIXcam
bu7TQmxSFsxibNObXKEilFX7Cmadp4pNEt4Z6Na8ekT6qZcWxUVPEcFtGfVxa2I=
=nW3K
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 01/26] gnu: Add rust-smallbitvec.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-1-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-smallbitvec-2): New variable.
---
gnu/packages/crates-io.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (33 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index fa9a7d9ab5..d001e723ec 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -56099,6 +56099,28 @@ (define-public rust-sluice-0.4
("rust-futures-core-preview" ,rust-futures-core-preview-0.3)
("rust-futures-io-preview" ,rust-futures-io-preview-0.3))))))

+(define-public rust-smallbitvec-2
+ (package
+ (name "rust-smallbitvec")
+ (version "2.5.1")
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri "smallbitvec" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0plrbldsjpwip3afbzd8fgrnvdhizcg5z4ncfqs4q6x4qjflzkkm"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-development-inputs
+ (("rust-bit-vec" ,rust-bit-vec-0.4)
+ ("rust-rand" ,rust-rand-0.4))))
+ (home-page "https://github.com/servo/smallbitvec")
+ (synopsis "A bit vector optimized for size and inline storage")
+ (description "This package provides a bit vector optimized for size and
+inline storage")
+ (license (list license:expat license:asl2.0))))
+
(define-public rust-smallvec-1
(package
(name "rust-smallvec")
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 02/26] gnu: Add rust-html-escape.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-2-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-html-escape-0.2): New variable.
---
gnu/packages/crates-io.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index d001e723ec..cff703c427 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -26933,6 +26933,30 @@ (define-public rust-htmlescape-0.3
"This package provides a library for HTML entity encoding and decoding.")
(license (list license:asl2.0 license:expat license:mpl2.0))))

+(define-public rust-html-escape-0.2
+ (package
+ (name "rust-html-escape")
+ (version "0.2.9")
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri "html-escape" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1dxw9lpckrqzzqgbkw64ckbajr4b7xxnjdn8adgzqf2mm40shvl1"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-utf8-width" ,rust-utf8-width-0.1))
+ #:cargo-development-inputs
+ (("rust-bencher" ,rust-bencher-0.1))))
+ (home-page "https://magiclen.org/html-escape")
+ (synopsis "Library for encoding and escaping special characters in HTML")
+ (description
+ "This package provides a library for encoding and escaping special
+characters in HTML, decoding and unescaping HTML entities as well.")
+ (license license:expat)))
+
(define-public rust-http-0.2
(package
(name "rust-http")
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 03/26] gnu: Add rust-spin@0.7.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-3-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-spin-0.7): New variable.
---
gnu/packages/crates-io.scm | 13 +++++++++++++
1 file changed, 13 insertions(+)

Toggle diff (24 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index cff703c427..ad27298404 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -56716,6 +56716,19 @@ (define-public rust-spin-0.9
initializers are available.")
(license license:expat)))

+(define-public rust-spin-0.7
+ (package
+ (inherit rust-spin-0.9)
+ (name "rust-spin")
+ (version "0.7.1")
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri "spin" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0qjips9f6fsvkyd7wj3a4gzaqknn2q4kkb19957pl86im56pna0k"))))))
+
(define-public rust-spin-0.5
(package
(inherit rust-spin-0.9)
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 05/26] gnu: Add tree-sitter-cli.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-5-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-cli): New variable.
---
gnu/packages/tree-sitter.scm | 68 +++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)

Toggle diff (86 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index e7d2ce113d..c2919e76b2 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -19,10 +19,13 @@
(define-module (gnu packages tree-sitter)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system cargo)
#:use-module (guix build-system gnu)
#:use-module (guix git-download)
#:use-module (guix packages)
- #:use-module (guix utils))
+ #:use-module (guix utils)
+ #:use-module (gnu packages crates-graphics)
+ #:use-module (gnu packages crates-io))

(define-public tree-sitter
(package
@@ -74,3 +77,66 @@ (define-public tree-sitter

This package includes the @code{libtree-sitter} runtime library.")
(license license:expat)))
+
+(define-public tree-sitter-cli
+ (package (inherit tree-sitter)
+ (name "tree-sitter-cli")
+ (build-system cargo-build-system)
+ (arguments
+ `(;; Running test requires downloading fixtures, see the
+ ;; script/fetch-fixtures script.
+ #:tests? #f
+ ;; FIXME: Installing the sources for the tree-sitter Rust bindings
+ ;; doesn't work out of the box due to tree-sitter having multiple
+ ;; Rust packages in the same repository (bindings and CLI).
+ #:install-source? #f
+ #:cargo-inputs
+ (("rust-ansi-term" ,rust-ansi-term-0.12)
+ ("rust-anyhow" ,rust-anyhow-1)
+ ("rust-atty" ,rust-atty-0.2)
+ ("rust-clap" ,rust-clap-2)
+ ("rust-difference" ,rust-difference-2)
+ ("rust-dirs" ,rust-dirs-3)
+ ("rust-html-escape" ,rust-html-escape-0.2)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-rustc-hash" ,rust-rustc-hash-1)
+ ("rust-serde" ,rust-serde-1)
+ ("rust-smallbitvec" ,rust-smallbitvec-2)
+ ("rust-spin" ,rust-spin-0.7)
+ ("rust-thiserror" ,rust-thiserror-1)
+ ("rust-tiny-http" ,rust-tiny-http-0.8)
+ ("rust-toml" ,rust-toml-0.5)
+ ("rust-walkdir" ,rust-walkdir-2)
+ ("rust-webbrowser" ,rust-webbrowser-0.5)
+ ("rust-which" ,rust-which-4))
+ #:cargo-development-inputs
+ (("rust-pretty-assertions" ,rust-pretty-assertions-0.7))
+ #: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)))))))
+ (synopsis "Incremental parsing system for programming tools")
+ (description "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @command{tree-sitter} command-line tool.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 04/26] gnu: Add tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-4-pierre.langlois@gmx.com
* gnu/package/tree-sitter.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Register it.
---
gnu/local.mk | 1 +
gnu/packages/tree-sitter.scm | 76 ++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 gnu/packages/tree-sitter.scm

Toggle diff (94 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 198c8f64a6..273d80a9c2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -584,6 +584,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/tmux.scm \
%D%/packages/toolkits.scm \
%D%/packages/tor.scm \
+ %D%/packages/tree-sitter.scm \
%D%/packages/tv.scm \
%D%/packages/uglifyjs.scm \
%D%/packages/uml.scm \
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
new file mode 100644
index 0000000000..e7d2ce113d
--- /dev/null
+++ b/gnu/packages/tree-sitter.scm
@@ -0,0 +1,76 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Pierre Langlois <pierre.langlois@gmx.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages tree-sitter)
+ #:use-module (guix gexp)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix git-download)
+ #:use-module (guix packages)
+ #:use-module (guix utils))
+
+(define-public tree-sitter
+ (package
+ (name "tree-sitter")
+ (version "0.20.4")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1yldgdbf3l5l4ki52abdf81nwkcbvg219gwr3ydcjwfsg7hf7zhz"))))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:tests? #f ;No check target.
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC"
+ #$(cc-for-target))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out")) (lib (string-append
+ out "/lib")))
+ (setenv "PREFIX" out)
+ (invoke "make" "install")))))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Incremental parsing system for programming tools")
+ (description
+ "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @code{libtree-sitter} runtime library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 07/26] gnu: Add tree-sitter-cpp.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-7-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-cpp): New variable.
---
gnu/packages/tree-sitter.scm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

Toggle diff (26 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index b62cb483c9..cc3bb2cec0 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -247,3 +247,21 @@ (define (source-file? basename)
(description
"This package provides a C grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-cpp
+ (package
+ (inherit tree-sitter-c)
+ (name "tree-sitter-cpp")
+ (version "0.20.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "0hxcpdvyyig8njga1mxp4qcnbbnr1d0aiy27vahijwbh98b081nr"))
+ (inputs
+ (list node-nan
+ `(,tree-sitter-c "js")))
+ (home-page "https://github.com/tree-sitter/tree-sitter-cpp")
+ (synopsis "Tree-sitter C++ grammar")
+ (description
+ "This package provides a C++ grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 08/26] gnu: Add tree-sitter-bash.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-8-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-bash): New variable.
---
gnu/packages/tree-sitter.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (32 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index cc3bb2cec0..827e1cdc4d 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -265,3 +265,27 @@ (define-public tree-sitter-cpp
(description
"This package provides a C++ grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-bash
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-bash")
+ (version "0.19.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "18c030bb65r50i6z37iy7jb9z9i8i36y7b08dbc9bchdifqsijs5"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'delete-dependencies
+ (lambda _
+ (delete-dependencies '("tree-sitter-cli"
+ "node-gyp"
+ "prebuild"
+ "prebuild-install"))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-bash")
+ (synopsis "Tree-sitter Bash grammar")
+ (description
+ "This package provides a Bash grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 09/26] gnu: Add tree-sitter-css.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-9-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-css): New variable.
---
gnu/packages/tree-sitter.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)

Toggle diff (22 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 827e1cdc4d..36b712c189 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -289,3 +289,17 @@ (define-public tree-sitter-bash
(description
"This package provides a Bash grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-css
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-css")
+ (version "0.19.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "014jrlgi7zfza9g38hsr4vlbi8964i5p7iglaih6qmzaiml7bja2"))
+ (home-page "https://github.com/tree-sitter/tree-sitter-css")
+ (synopsis "Tree-sitter CSS grammar")
+ (description
+ "This package provides a CSS grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 11/26] gnu: Add tree-sitter-html.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-11-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-html): New variable.
---
gnu/packages/tree-sitter.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)

Toggle diff (22 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 47f102b0b3..e4679dc8ab 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -326,3 +326,17 @@ (define-public tree-sitter-go
(description
"This package provides a Golang grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-html
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-html")
+ (version "0.19.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "1hg7vbcy7bir6b8x11v0a4x0glvqnsqc3i2ixiarbxmycbgl3axy"))
+ (home-page "https://github.com/tree-sitter/tree-sitter-html")
+ (synopsis "Tree-sitter HTML grammar")
+ (description
+ "This package provides a HTML grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 12/26] gnu: Add tree-sitter-java.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-12-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-java): New variable.
---
gnu/packages/tree-sitter.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index e4679dc8ab..760a7871df 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -340,3 +340,26 @@ (define-public tree-sitter-html
(description
"This package provides a HTML grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-java
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-java")
+ (version "0.19.1")
+ (source (tree-sitter-origin
+ name
+ version
+ "07zw9ygb45hnvlx9qlz7rlz8hc3byjy03d24v72i5iyhpiiwlhvl"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-java")
+ (synopsis "Tree-sitter Java grammar")
+ (description
+ "This package provides a Java grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 10/26] gnu: Add tree-sitter-go.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-10-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-go): New variable.
---
gnu/packages/tree-sitter.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 36b712c189..47f102b0b3 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -303,3 +303,26 @@ (define-public tree-sitter-css
(description
"This package provides a CSS grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-go
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-go")
+ (version "0.19.1")
+ (source (tree-sitter-origin
+ name
+ version
+ "0nxs47vd2fc2fr0qlxq496y852rwg39flhg334s7dlyq7d3lcx4x"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-go")
+ (synopsis "Tree-sitter Go grammar")
+ (description
+ "This package provides a Golang grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 13/26] gnu: Add tree-sitter-javascript.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-13-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-javascript): New variable.
---
gnu/packages/tree-sitter.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (32 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 760a7871df..b728e6511b 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -363,3 +363,27 @@ (define-public tree-sitter-java
(description
"This package provides a Java grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-javascript
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-javascript")
+ (version "0.20.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "175yrk382n2di0c2xn4gpv8y4n83x1lg4hqn04vabf0yqynlkq67"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-javascript")
+ (synopsis "Tree-sitter Javascript grammar")
+ (description
+ "This package provides a Javascript grammar for the Tree-sitter
+library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 14/26] gnu: Add tree-sitter-json.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-14-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-json): New variable.
---
gnu/packages/tree-sitter.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)

Toggle diff (22 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index b728e6511b..d35edc533d 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -387,3 +387,17 @@ (define-public tree-sitter-javascript
"This package provides a Javascript grammar for the Tree-sitter
library.")
(license license:expat)))
+
+(define-public tree-sitter-json
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-json")
+ (version "0.19.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "06pjh31bv9ja9hlnykk257a6zh8bsxg2fqa54al7qk1r4n9ksnff"))
+ (home-page "https://github.com/tree-sitter/tree-sitter-json")
+ (synopsis "Tree-sitter JSON grammar")
+ (description
+ "This package provides a JSON grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 15/26] gnu: Add tree-sitter-julia.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-15-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-julia): New variable.
---
gnu/packages/tree-sitter.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index d35edc533d..aeb541224a 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -401,3 +401,26 @@ (define-public tree-sitter-json
(description
"This package provides a JSON grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-julia
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-julia")
+ (version "0.19.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "1pbnmvhy2gq4vg1b0sjzmjm4s2gsgdjh7h01yj8qrrqbcl29c463"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-julia")
+ (synopsis "Tree-sitter Julia grammar")
+ (description
+ "This package provides a Julia grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 16/26] gnu: Add tree-sitter-php.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-16-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-php): New variable.
---
gnu/packages/tree-sitter.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index aeb541224a..072d2bf588 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -424,3 +424,26 @@ (define-public tree-sitter-julia
(description
"This package provides a Julia grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-php
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-php")
+ (version "0.19.0")
+ (source (tree-sitter-origin
+ name
+ version
+ "17cmybgpprw7w9d2v7lmc6zmr90d70g0jqq279gzg0mpwfzla53s"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-php")
+ (synopsis "Tree-sitter PHP grammar")
+ (description
+ "This package provides a PHP grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 17/26] gnu: Add tree-sitter-python.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-17-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-python): New variable.
---
gnu/packages/tree-sitter.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

Toggle diff (31 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 072d2bf588..05d6ade77d 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -447,3 +447,26 @@ (define-public tree-sitter-php
(description
"This package provides a PHP grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-python
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-python")
+ (version "0.19.1")
+ (source (tree-sitter-origin
+ name
+ version
+ "16i5mcpz4ld0rybffb0nxim4crb9fhnnq20b4bkjs7jjr3zcx7vq"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-python")
+ (synopsis "Tree-sitter Python grammar")
+ (description
+ "This package provides a Python grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 19/26] gnu: Add tree-sitter-typescript.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-19-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-typescript): New variable.
---
gnu/packages/tree-sitter.scm | 87 ++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)

Toggle diff (95 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 63e558f50f..2dcf4dae87 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -488,3 +488,90 @@ (define-public tree-sitter-rust
(description
"This package provides a Rust grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-typescript
+ (let ((commit "111b07762e86efab9a918b7c721f720c37e76b0a")
+ (revision "1"))
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-typescript")
+ (version (git-version "0.20.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-typescript")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1364bm3wbqqzvp03cvpx1w89bbqynb1v62i46gy7f6rhib9bf63a"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ (for-each
+ (lambda (lang)
+ (with-directory-excursion lang
+ (delete-file "src/grammar.json")
+ (delete-file "src/node-types.json")
+ (delete-file "src/parser.c")
+ (delete-file-recursively "src/tree_sitter")))
+ '("typescript" "tsx"))
+ #t))))
+ (inputs
+ (list node-nan
+ `(,tree-sitter-javascript "js")))
+ (arguments
+ (substitute-keyword-arguments (package-arguments tree-sitter-c)
+ ((#:phases phases)
+ #~(modify-phases #$phases
+ ;; The parse-example script tries to clone git repositories.
+ (add-after 'unpack 'remove-parse-example
+ (lambda _
+ (substitute* "package.json"
+ ((" && script\\/parse-examples") ""))))
+ (add-after 'build 'build-gyp
+ (lambda* (#:key inputs #:allow-other-keys)
+ (invoke
+ (search-input-file
+ inputs
+ "/lib/node_modules/npm/bin/node-gyp-bin/node-gyp")
+ "build")))
+ (replace 'tree-sitter-generate
+ (lambda _
+ (for-each (lambda (dir)
+ (with-directory-excursion dir
+ (invoke "tree-sitter" "generate")))
+ '("typescript" "tsx"))))
+ (replace 'build-and-install-lib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (use-modules (guix build json))
+ (let ((name (assoc-ref
+ (call-with-input-file "package.json" read-json)
+ "name"))
+ (lib (string-append #$output "/lib/tree-sitter/")))
+ (mkdir-p lib)
+ (define (source-file? basename)
+ "document me"
+ (let ((path (string-append src "/" basename)))
+ (if (file-exists? path)
+ path
+ #f)))
+ (for-each
+ (lambda (lang)
+ (let ((src (string-append #$output:js
+ "/lib/node_modules/"
+ name "/" lang "/src")))
+ (invoke #$(cc-for-target)
+ "-shared"
+ "-fPIC"
+ "-fno-exceptions"
+ "-O2"
+ "-g"
+ "-o" (string-append lib "/" lang ".so")
+ (string-append src "/scanner.c")
+ (string-append src "/parser.c"))))
+ '("typescript" "tsx")))))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-typescript")
+ (synopsis "Tree-sitter Typescript grammar")
+ (description
+ "This package provides Typescript and TSX grammars for the Tree-sitter
+library.")
+ (license license:expat))))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 18/26] gnu: Add tree-sitter-rust.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-18-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-rust): New variable.
---
gnu/packages/tree-sitter.scm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

Toggle diff (33 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 05d6ade77d..63e558f50f 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -26,6 +26,7 @@ (define-module (gnu packages tree-sitter)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (gnu packages algebra)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages node-xyz)
@@ -470,3 +471,20 @@ (define-public tree-sitter-python
(description
"This package provides a Python grammar for the Tree-sitter library.")
(license license:expat)))
+
+(define-public tree-sitter-rust
+ (package (inherit tree-sitter-c)
+ (name "tree-sitter-rust")
+ (version "0.20.1")
+ (source (tree-sitter-origin
+ name
+ version
+ "174j5pxwf80c4xniri39l3a6bb7nq96g2s8hh5sgv4i7xvbpfsmg"))
+ (native-inputs
+ (modify-inputs (package-native-inputs tree-sitter-c)
+ (prepend bc)))
+ (home-page "https://github.com/tree-sitter/tree-sitter-rust")
+ (synopsis "Tree-sitter Rust grammar")
+ (description
+ "This package provides a Rust grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 21/26] gnu: rust-emacs-module: Update to 0.18.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-21-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-module-0.18): New variable.
(rust-emacs-module-0.10): Inherit from rust-emacs-module-0.18.
---
gnu/packages/crates-io.scm | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index ad27298404..c039591c56 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -19090,10 +19090,10 @@ (define-public rust-emacs-macros-0.11
(description "This package provides proc macros for Emacs modules.")
(license license:bsd-3)))

-(define-public rust-emacs-module-0.10
+(define-public rust-emacs-module-0.18
(package
(name "rust-emacs-module")
- (version "0.10.0")
+ (version "0.18.0")
(source
(origin
(method url-fetch)
@@ -19102,11 +19102,11 @@ (define-public rust-emacs-module-0.10
(string-append name "-" version ".tar.gz"))
(sha256
(base32
- "1gf9lz735xbkyir53dyv362drfx3nin5an5cx39kd8q8kjjwix5g"))))
+ "1ypjyyv2ca3vza4sia91ckxamgfk63yd8frkvg3d4ph4fk4pn1mk"))))
(build-system cargo-build-system)
(arguments
`(#:cargo-inputs
- (("rust-bindgen" ,rust-bindgen-0.48))))
+ (("rust-bindgen" ,rust-bindgen-0.59))))
(inputs
(list clang))
(home-page "https://github.com/ubolonton/emacs-module-rs")
@@ -19115,6 +19115,23 @@ (define-public rust-emacs-module-0.10
Emacs' support for dynamic modules.")
(license license:bsd-3)))

+(define-public rust-emacs-module-0.10
+ (package (inherit rust-emacs-module-0.18)
+ (name "rust-emacs-module")
+ (version "0.10.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs_module" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1gf9lz735xbkyir53dyv362drfx3nin5an5cx39kd8q8kjjwix5g"))))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-bindgen" ,rust-bindgen-0.48))))))
+
(define-public rust-email-0.0.20
(package
(name "rust-email")
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 20/26] gnu: Add rust-tree-sitter-for-emacs.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-20-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (rust-tree-sitter-for-emacs): New variable.
* gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
gnu/local.mk | 1 +
.../rust-tree-sitter-text-provider-fix.patch | 98 +++++++++++++++++++
gnu/packages/tree-sitter.scm | 45 +++++++++
3 files changed, 144 insertions(+)
create mode 100644 gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch

Toggle diff (182 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 273d80a9c2..f2b6f0afdd 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1811,6 +1811,7 @@ dist_patch_DATA = \
%D%/packages/patches/rust-nettle-sys-disable-vendor.patch \
%D%/packages/patches/rust-openssl-sys-no-vendor.patch \
%D%/packages/patches/rust-shell2batch-lint-fix.patch \
+ %D%/packages/patches/rust-tree-sitter-text-provider-fix.patch \
%D%/packages/patches/rust-wl-clipboard-rs-newer-wl.patch \
%D%/packages/patches/sbc-fix-build-non-x86.patch \
%D%/packages/patches/sbcl-aserve-add-HTML-5-elements.patch \
diff --git a/gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch b/gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch
new file mode 100644
index 0000000000..beda2d8391
--- /dev/null
+++ b/gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch
@@ -0,0 +1,98 @@
+From 475b822f47bdc58d832533448b6f6d9818554f37 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Tu=E1=BA=A5n-Anh=20Nguy=E1=BB=85n?= <ubolonton@gmail.com>
+Date: Sun, 25 Jul 2021 13:11:52 +0700
+Subject: [PATCH] Allow TextProvider's iterators to generate owned text
+
+---
+ binding_rust/lib.rs | 33 ++++++++++++++++++---------------
+ 1 file changed, 18 insertions(+), 15 deletions(-)
+
+diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs
+index 068a60285..79c3991ed 100644
+--- a/binding_rust/lib.rs
++++ b/binding_rust/lib.rs
+@@ -8,6 +8,7 @@ pub mod allocations;
+ use std::os::unix::io::AsRawFd;
+
+ use std::{
++ borrow::Cow,
+ char, error,
+ ffi::CStr,
+ fmt, hash, iter,
+@@ -162,7 +163,8 @@ pub struct QueryCaptures<'a, 'tree: 'a, T: TextProvider<'a>> {
+ }
+
+ pub trait TextProvider<'a> {
+- type I: Iterator<Item = &'a [u8]> + 'a;
++ type I: Iterator<Item = Cow<'a, [u8]>>;
++
+ fn text(&mut self, node: Node) -> Self::I;
+ }
+
+@@ -1799,19 +1801,19 @@ impl<'a, 'tree> QueryMatch<'a, 'tree> {
+ buffer2: &mut Vec<u8>,
+ text_provider: &mut impl TextProvider<'a>,
+ ) -> bool {
+- fn get_text<'a, 'b: 'a, I: Iterator<Item = &'b [u8]>>(
++ fn get_text<'a, 'b: 'a, I: Iterator<Item = Cow<'b, [u8]>>>(
+ buffer: &'a mut Vec<u8>,
+ mut chunks: I,
+- ) -> &'a [u8] {
+- let first_chunk = chunks.next().unwrap_or(&[]);
++ ) -> Cow<'a, [u8]> {
++ let first_chunk = chunks.next().unwrap_or(Cow::Owned(vec![0u8; 0]));
+ if let Some(next_chunk) = chunks.next() {
+ buffer.clear();
+- buffer.extend_from_slice(first_chunk);
+- buffer.extend_from_slice(next_chunk);
++ buffer.extend_from_slice(&first_chunk);
++ buffer.extend_from_slice(&next_chunk);
+ for chunk in chunks {
+- buffer.extend_from_slice(chunk);
++ buffer.extend_from_slice(&chunk);
+ }
+- buffer.as_slice()
++ Cow::Borrowed(buffer.as_slice())
+ } else {
+ first_chunk
+ }
+@@ -1835,7 +1837,7 @@ impl<'a, 'tree> QueryMatch<'a, 'tree> {
+ TextPredicate::CaptureMatchString(i, r, is_positive) => {
+ let node = self.nodes_for_capture_index(*i).next().unwrap();
+ let text = get_text(buffer1, text_provider.text(node));
+- r.is_match(text) == *is_positive
++ r.is_match(&text) == *is_positive
+ }
+ })
+ }
+@@ -1946,23 +1948,24 @@ impl<'cursor, 'tree> fmt::Debug for QueryMatch<'cursor, 'tree> {
+ }
+ }
+
+-impl<'a, F, I> TextProvider<'a> for F
++impl<'a, F, I, T> TextProvider<'a> for F
+ where
+ F: FnMut(Node) -> I,
+- I: Iterator<Item = &'a [u8]> + 'a,
++ T: Into<Cow<'a, [u8]>>,
++ I: Iterator<Item = T>,
+ {
+- type I = I;
++ type I = iter::Map<I, fn(T) -> Cow<'a, [u8]>>;
+
+ fn text(&mut self, node: Node) -> Self::I {
+- (self)(node)
++ (self)(node).map(T::into)
+ }
+ }
+
+ impl<'a> TextProvider<'a> for &'a [u8] {
+- type I = iter::Once<&'a [u8]>;
++ type I = iter::Once<Cow<'a, [u8]>>;
+
+ fn text(&mut self, node: Node) -> Self::I {
+- iter::once(&self[node.byte_range()])
++ iter::once(Cow::Borrowed(&self[node.byte_range()]))
+ }
+ }
+
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 2dcf4dae87..c86244a300 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -23,9 +23,11 @@ (define-module (gnu packages tree-sitter)
#:use-module (guix build-system gnu)
#:use-module (guix build-system node)
#:use-module (guix gexp)
+ #:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (gnu packages)
#:use-module (gnu packages algebra)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages crates-io)
@@ -146,6 +148,49 @@ (define-public tree-sitter-cli
This package includes the @command{tree-sitter} command-line tool.")
(license license:expat)))

+;; We need to apply a patch in order to compile the rust bindings against the
+;; emacs tree-sitter module.
+;; See https://github.com/tree-sitter/tree-sitter/pull/1294
+(define-public rust-tree-sitter-for-emacs
+ (package
+ (name "rust-tree-sitter")
+ (version "0.20.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "tree-sitter" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1yg4p54hsfsxxknjq492i8b4rvibzpl2zdvr2bwvwakqgah05v33"))
+ (patches (search-patches "rust-tree-sitter-text-provider-fix.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; Force
+ (delete-file-recursively "src")
+ (delete-file "binding_rust/build.rs")
+ (with-output-to-file "binding_rust/build.rs"
+ (lambda _
+ (format #t "fn main() {~@
+ println!(\"cargo:rustc-link-lib=tree-sitter\");~@
+ }~%")))
+ #f))))
+ (build-system cargo-build-system)
+ (inputs (list tree-sitter))
+ (arguments
+ `(#:tests? #f ;; Running tests misinterprets comments as doc-tests.
+ #:cargo-inputs
+ (("rust-cc" ,rust-cc-1)
+ ("rust-lazy-static" ,rust-lazy-static-1)
+ ("rust-regex" ,rust-regex-1)
+ ("rust-spin" ,rust-spin-0.7))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Rust bindings to the Tree-sitter parsing library")
+ (description "This package provides Rust bindings to the Tree-sitter
+parsing library.")
+ (license license:expat)))
+
(define (tree-sitter-origin name version hash)
(origin
(method git-fetch)
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 22/26] gnu: rust-emacs-macros: Update to 0.17.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-22-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-macros-0.17): New variable.
(rust-emacs-macros-0.11): Inherit from rust-emacs-macros-0.17.
---
gnu/packages/crates-io.scm | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)

Toggle diff (55 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index c039591c56..ea2e9c9328 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -19066,8 +19066,31 @@ (define-public rust-emacs-0.11
Emacs' support for dynamic modules.")
(license license:bsd-3)))

-(define-public rust-emacs-macros-0.11
+(define-public rust-emacs-macros-0.17
(package
+ (name "rust-emacs-macros")
+ (version "0.17.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs-macros" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0qg1dcn5acbirq617qq2fgg9adswif2dnr292s3qnq62wzgnyrb9"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-darling" ,rust-darling-0.10)
+ ("rust-quote" ,rust-quote-1)
+ ("rust-syn" ,rust-syn-1))))
+ (home-page "https://github.com/ubolonton/emacs-module-rs")
+ (synopsis "Proc macros for Emacs modules")
+ (description "This package provides proc macros for Emacs modules.")
+ (license license:bsd-3)))
+
+(define-public rust-emacs-macros-0.11
+ (package (inherit rust-emacs-macros-0.17)
(name "rust-emacs-macros")
(version "0.11.0")
(source
@@ -19079,16 +19102,11 @@ (define-public rust-emacs-macros-0.11
(sha256
(base32
"0390y8vafxdi334hhgrzvcqjq3n5ckcmvilqcfp8vajjq8irrly6"))))
- (build-system cargo-build-system)
(arguments
`(#:cargo-inputs
(("rust-darling" ,rust-darling-0.9)
("rust-quote" ,rust-quote-0.6)
- ("rust-syn" ,rust-syn-0.15))))
- (home-page "https://github.com/ubolonton/emacs-module-rs")
- (synopsis "Proc macros for Emacs modules")
- (description "This package provides proc macros for Emacs modules.")
- (license license:bsd-3)))
+ ("rust-syn" ,rust-syn-0.15))))))

(define-public rust-emacs-module-0.18
(package
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 24/26] gnu: Add emacs-tree-sitter-core.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-24-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable.
(emacs-tree-sitter-core): New variable.
---
gnu/packages/tree-sitter.scm | 78 ++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)

Toggle diff (93 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index c86244a300..893c02824d 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -20,6 +20,7 @@ (define-module (gnu packages tree-sitter)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
+ #:use-module (guix build-system emacs)
#:use-module (guix build-system gnu)
#:use-module (guix build-system node)
#:use-module (guix gexp)
@@ -620,3 +621,80 @@ (define (source-file? basename)
"This package provides Typescript and TSX grammars for the Tree-sitter
library.")
(license license:expat))))
+
+;; Local package definition solely for building the native emacs module
+;; written in Rust.
+(define tree-sitter-emacs-module
+ (package
+ (name "tree-sitter-emacs-module")
+ (version "0.17.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0bl7709r4mhb5nmfcsiqj09ja8wn53x9nf5jrr5lq3n1lwz7qq66"))))
+ (build-system cargo-build-system)
+ (inputs
+ (list tree-sitter))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-emacs" ,rust-emacs-0.18)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-tree-sitter" ,rust-tree-sitter-for-emacs))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "core")))
+ (add-after 'chdir 'delete-cargo.lock
+ (lambda _ (delete-file "Cargo.lock")))
+ (add-after 'delete-cargo.lock 'do-not-fetch-from-github
+ (lambda _
+ (substitute* "Cargo.toml"
+ (("\\[patch.*") "")
+ (("git = .*") ""))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
+ (install-file "target/release/libtsc_dyn.so" lib)))))))
+ (home-page #f)
+ (synopsis #f)
+ (description #f)
+ (license license:expat)))
+
+(define-public emacs-tree-sitter-core
+ (package
+ (name "emacs-tree-sitter-core")
+ (version (package-version tree-sitter-emacs-module))
+ (source (package-source tree-sitter-emacs-module))
+ (build-system emacs-build-system)
+ (native-inputs
+ (list tree-sitter-emacs-module))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "core")))
+ (add-after 'install 'install-module
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out")))
+ (module (string-append (assoc-ref inputs "tree-sitter-emacs-module")
+ "/lib/libtsc_dyn.so")))
+ ;; Writing "LOCAL" in this file prevents the package from
+ ;; trying to download the module from the internet.
+ (call-with-output-file (string-append elpa "/DYN-VERSION")
+ (lambda (port) (display "LOCAL" port)))
+ (substitute* "tsc-dyn-get.el"
+ (("defcustom tsc-dyn-dir tsc--dir")
+ (string-append "defcustom tsc-dyn-dir \"" elpa "\"")))
+ (copy-file module (string-append elpa "/tsc-dyn.so"))))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp, core library")
+ (description "This package provides core APIs of the Emacs binding for
+Tree-sitter, an incremental parsing system.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 23/26] gnu: rust-emacs: Update to 0.18.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-23-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-emacs-0.18): New variable.
(rust-emacs-0.11): Inherit from rust-emacs-0.18.
---
gnu/packages/crates-io.scm | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)

Toggle diff (70 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index ea2e9c9328..f9ea194438 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -19035,10 +19035,10 @@ (define-public rust-elf-0.0.10
"This package provides a pure-Rust library for parsing ELF files.")
(license (list license:expat license:asl2.0))))

-(define-public rust-emacs-0.11
+(define-public rust-emacs-0.18
(package
(name "rust-emacs")
- (version "0.11.0")
+ (version "0.18.0")
(source
(origin
(method url-fetch)
@@ -19047,16 +19047,18 @@ (define-public rust-emacs-0.11
(string-append name "-" version ".tar.gz"))
(sha256
(base32
- "1xn6nr8m3p24irlmv3i7c9n95yb10qc6aikwqv99qlmhbky5x0z7"))))
+ "0r860i73b2680i2fhdl2l1wwvvmf2zksncpckgkksdcx310ak5v7"))))
(build-system cargo-build-system)
(arguments
`(#:cargo-inputs
- (("rust-ctor" ,rust-ctor-0.1)
- ("rust-emacs-macros" ,rust-emacs-macros-0.11)
- ("rust-emacs-module" ,rust-emacs-module-0.10)
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-ctor" ,rust-ctor-0.1)
+ ("rust-emacs-macros" ,rust-emacs-macros-0.17)
+ ("rust-emacs-module" ,rust-emacs-module-0.18)
("rust-failure" ,rust-failure-0.1)
("rust-failure-derive" ,rust-failure-derive-0.1)
- ("rust-lazy-static" ,rust-lazy-static-1))))
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-thiserror" ,rust-thiserror-1))))
(inputs
(list clang))
(home-page "https://github.com/ubolonton/emacs-module-rs")
@@ -19066,6 +19068,28 @@ (define-public rust-emacs-0.11
Emacs' support for dynamic modules.")
(license license:bsd-3)))

+(define-public rust-emacs-0.11
+ (package (inherit rust-emacs-0.18)
+ (name "rust-emacs")
+ (version "0.11.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "emacs" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1xn6nr8m3p24irlmv3i7c9n95yb10qc6aikwqv99qlmhbky5x0z7"))))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-ctor" ,rust-ctor-0.1)
+ ("rust-emacs-macros" ,rust-emacs-macros-0.11)
+ ("rust-emacs-module" ,rust-emacs-module-0.10)
+ ("rust-failure" ,rust-failure-0.1)
+ ("rust-failure-derive" ,rust-failure-derive-0.1)
+ ("rust-lazy-static" ,rust-lazy-static-1))))))
+
(define-public rust-emacs-macros-0.17
(package
(name "rust-emacs-macros")
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 25/26] gnu: Add emacs-tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-25-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (emacs-tree-sitter): New variable.
---
gnu/packages/tree-sitter.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 893c02824d..b412f3d031 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -698,3 +698,30 @@ (module (string-append (assoc-ref inputs "tree-sitter-emacs-module")
(description "This package provides core APIs of the Emacs binding for
Tree-sitter, an incremental parsing system.")
(license license:expat)))
+
+(define-public emacs-tree-sitter
+ (package
+ (name "emacs-tree-sitter")
+ (version (package-version emacs-tree-sitter-core))
+ (source (package-source emacs-tree-sitter-core))
+ (build-system emacs-build-system)
+ (propagated-inputs
+ (list emacs-tree-sitter-core))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "lisp"))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp")
+ (description "This package provides Emacs bindings for Tree-sitter, an
+incremental parsing library. It aims to be the foundation for a new breed of
+Emacs packages that understand code structurally. For example:
+
+@enumerate
+@item Faster, fine-grained code highlighting.
+@item More flexible code folding.
+@item Structural editing (like Paredit, or even better) for non-Lisp code.
+@item More informative indexing for imenu.
+@end enumerate")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 10 Feb 2022 23:55
[WIP PATCH v3 26/26] gnu: Add emacs-tree-sitter-langs.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220210225527.25189-26-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (emacs-tree-sitter-langs): New variable.
---
gnu/packages/tree-sitter.scm | 81 ++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)

Toggle diff (89 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index b412f3d031..00b91f5c91 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -725,3 +725,84 @@ (define-public emacs-tree-sitter
@item More informative indexing for imenu.
@end enumerate")
(license license:expat)))
+
+(define-public emacs-tree-sitter-langs
+ (package
+ (name "emacs-tree-sitter-langs")
+ (version "0.11.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/tree-sitter-langs")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0r3yw25czg1vcxk9015yd8p1n0z427z2l4hizfjy8w8jjjg7cxxf"))))
+ (build-system emacs-build-system)
+ ;; FIXME: Support for some languages, such as ruby, is still missing from
+ ;; the bundle.
+ (inputs
+ (list tree-sitter-bash
+ tree-sitter-c
+ tree-sitter-cpp
+ tree-sitter-css
+ tree-sitter-go
+ tree-sitter-html
+ tree-sitter-java
+ tree-sitter-javascript
+ tree-sitter-json
+ tree-sitter-julia
+ tree-sitter-php
+ tree-sitter-python
+ tree-sitter-rust
+ tree-sitter-typescript))
+ (propagated-inputs
+ (list emacs-tree-sitter))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'build 'fake-bundle
+ (lambda _
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file "bin/BUNDLE-VERSION"
+ (lambda (port) (display ,version port)))))
+ (add-after 'install 'install-libs
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (mkdir-p (string-append elpa "/bin"))
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file (string-append elpa "/bin/BUNDLE-VERSION")
+ (lambda (port) (display ,version port)))
+
+ (define (install-lib lang)
+ (let ((input (assoc-ref inputs (string-append "tree-sitter-" lang))))
+ (symlink (string-append input "/lib/tree-sitter/" lang ".so")
+ (string-append elpa "/bin/" lang ".so"))))
+ (for-each (lambda (input)
+ (use-modules (ice-9 regex))
+ (cond
+ ((string-match "^tree-sitter-(.*)$" (car input))
+ => (lambda (m)
+ (install-lib (match:substring m 1))))))
+ inputs))))
+ (add-after 'install 'install-queries
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (copy-recursively "queries" (string-append elpa "/queries"))))))))
+ (home-page "https://ubolonton.github.io/emacs-tree-sitter/languages/")
+ (synopsis "Language support bundle for Tree-sitter")
+ (description "This package is a convenient language bundle for
+Tree-sitter. For each supported language, this package provides:
+
+@enumerate
+@item Pre-compiled grammar binaries.
+@item An optional highlights.scm file that provides highlighting patterns.
+This is mainly intended for major modes that are not aware of tree-sitter.
+@item Optional query patterns for other minor modes that provide high-level
+functionalities on top of tree-sitter, such as code folding, evil text
+objects, ...etc.
+@end enumerate")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 18 Feb 2022 15:12
[PATCH v4 00/31] gnu: Add tree-sitter for emacs.
(address . 49946@debbugs.gnu.org)
877d9s2qa9.fsf@gmx.com
Hi Guix!

Here's a v4 that's in a pretty good shape IMO. Here's a summary of the
changes compared to previous versions, there were lots actually! :-)

- Removed bundled icu4c headers from `tree-sitter', as pointed out on

- Added a snippet that removes all files generated by the
`tree-sitter generate' command, to be used in all grammar packages.

- For each grammar package, provide two outputs:

* "out": With just the compiled grammar.

Toggle snippet (10 lines)
/gnu/store/mb2hcaanm6ld8rx19p1ihk2fs1m7lcj8-tree-sitter-c-0.20.1
??? lib
?   ??? tree-sitter
?   ??? c.so
??? share
??? doc
??? tree-sitter-c-0.20.1
??? LICENSE

* "js": With the JS package output, so that it may be used as a
dependency. For example C++ imports the C grammar, and Typescript
imports JavaScript.

- Removed the dependency on node-gyp!

By default, the `npm' build system builds JavaScript bindings for each
grammar, so that node applications may use them as a library to parse
a given language. We don't need this yet in Guix, we just want to
generate C code from the JS grammar description and compile it.

So when invoking `tree-sitter generate', we disable bindings
generation and then we ignore all custom scripts when installing the
JS package. This simplifies grammar packages a *lot*, given those
custom script often try to download binaries and would have had to be
patched.

- Grammars are compiled manually.

Previous versions relied on doing `tree-sitter test' so that a grammar
would be loaded and compiled by `tree-sitter' into its own cache. We
would then install the library from that cache location, which can
change across versions.

This felt like a hack, looking at the source code, we're just
compiling a couple of files at most, we can do that ourselve.

- I added support for a few extra languages, like ruby, C#, elixir and
ocaml.

- Last but very much not least, tests for emacs-tree-sitter-langs are
enabled!

This is important because this package doesn't just bundle all the
grammars, it also provides custom highlighting rules, which depend on
the grammar and can easily be out-of-sync and break. Thanks to
enabling these tests, I realized the php grammar need updating and
didn't work for example.

Let me know if you have any feedback on this series! It's taking me
quite some time to follow it through, it's not the easiest thing to
package :-/.

I do wonder if I'm going about it the right way for Guix though, for
instance I'm wondering if I should rewrite the grammar packages using a
new custom build system, do people think it would be worth it? That
could be done as a follow-up of course.

Thanks,
Pierre

Pierre Langlois (31):
gnu: Add rust-smallbitvec.
gnu: Add rust-html-escape.
gnu: Add rust-spin@0.7.
gnu: Add tree-sitter.
gnu: Add tree-sitter-cli.
gnu: Add tree-sitter-c.
gnu: Add tree-sitter-cpp.
gnu: Add tree-sitter-bash.
gnu: Add tree-sitter-css.
gnu: Add tree-sitter-c-sharp.
gnu: Add tree-sitter-elixir.
gnu: Add tree-sitter-elm.
gnu: Add tree-sitter-go.
gnu: Add tree-sitter-html.
gnu: Add tree-sitter-java.
gnu: Add tree-sitter-javascript.
gnu: Add tree-sitter-json.
gnu: Add tree-sitter-julia.
gnu: Add tree-sitter-ocaml.
gnu: Add tree-sitter-php.
gnu: Add tree-sitter-python.
gnu: Add tree-sitter-ruby.
gnu: Add tree-sitter-rust.
gnu: Add tree-sitter-typescript.
gnu: Add rust-tree-sitter-for-emacs.
gnu: rust-emacs-module: Update to 0.18.
gnu: rust-emacs-macros: Update to 0.17.
gnu: rust-emacs: Update to 0.18.
gnu: Add emacs-tree-sitter-core.
gnu: Add emacs-tree-sitter.
gnu: Add emacs-tree-sitter-langs.

gnu/local.mk | 2 +
gnu/packages/crates-io.scm | 154 ++-
.../rust-tree-sitter-text-provider-fix.patch | 98 ++
gnu/packages/tree-sitter.scm | 1088 +++++++++++++++++
4 files changed, 1324 insertions(+), 18 deletions(-)
create mode 100644 gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch
create mode 100644 gnu/packages/tree-sitter.scm

--
2.34.0
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmIPr24YHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31U3M0IAKDg2dimfgTh9aElA7Vx2Rpd
JvCCl4RpfcvCSoxSTwwd1x8pzuCYlvjrTCSrT+byqxFVg0kjexTSPymtPKZRSyT5
VB2tzPGkaFaud2WwHptE2s7fRC45zUfXupyuc7cDA6hWtCTBCCvlcSVrvPCr6vXa
NGxC6gCuFb3samZPV/tImMBA5+h0R/HoZ9j3I8FFj9KwV3l7bbT0CG3Przdyfjpd
rvUO41AH4WChFT4p8haTG+Mlp/Pl+0LvaZewUBDNHJOrjeni9814Jqzx9nKEcyMr
/D1m3j7oWWAf1qDIXV9o8u1fqRZOPeBEdOieuJ4vtJWl3Va+1so5BKBxK89ySlg=
=8jYk
-----END PGP SIGNATURE-----

P
P
Pierre Langlois wrote on 18 Feb 2022 15:39
[PATCH v4 01/31] gnu: Add rust-smallbitvec.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220218143948.28989-1-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-smallbitvec-2): New variable.
---
gnu/packages/crates-io.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Toggle diff (33 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 6024c9c57a..291c289b5a 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -56109,6 +56109,28 @@ (define-public rust-sluice-0.4
("rust-futures-core-preview" ,rust-futures-core-preview-0.3)
("rust-futures-io-preview" ,rust-futures-io-preview-0.3))))))

+(define-public rust-smallbitvec-2
+ (package
+ (name "rust-smallbitvec")
+ (version "2.5.1")
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri "smallbitvec" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0plrbldsjpwip3afbzd8fgrnvdhizcg5z4ncfqs4q6x4qjflzkkm"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-development-inputs
+ (("rust-bit-vec" ,rust-bit-vec-0.4)
+ ("rust-rand" ,rust-rand-0.4))))
+ (home-page "https://github.com/servo/smallbitvec")
+ (synopsis "A bit vector optimized for size and inline storage")
+ (description "This package provides a bit vector optimized for size and
+inline storage")
+ (license (list license:expat license:asl2.0))))
+
(define-public rust-smallvec-1
(package
(name "rust-smallvec")
--
2.34.0
P
P
Pierre Langlois wrote on 18 Feb 2022 15:39
[PATCH v4 02/31] gnu: Add rust-html-escape.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220218143948.28989-2-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-html-escape-0.2): New variable.
---
gnu/packages/crates-io.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

Toggle diff (35 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 291c289b5a..986901740a 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -26943,6 +26943,30 @@ (define-public rust-htmlescape-0.3
"This package provides a library for HTML entity encoding and decoding.")
(license (list license:asl2.0 license:expat license:mpl2.0))))

+(define-public rust-html-escape-0.2
+ (package
+ (name "rust-html-escape")
+ (version "0.2.9")
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri "html-escape" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1dxw9lpckrqzzqgbkw64ckbajr4b7xxnjdn8adgzqf2mm40shvl1"))))
+ (build-system cargo-build-system)
+ (arguments
+ `(#:cargo-inputs
+ (("rust-utf8-width" ,rust-utf8-width-0.1))
+ #:cargo-development-inputs
+ (("rust-bencher" ,rust-bencher-0.1))))
+ (home-page "https://magiclen.org/html-escape")
+ (synopsis "Library for encoding and escaping special characters in HTML")
+ (description
+ "This package provides a library for encoding and escaping special
+characters in HTML, decoding and unescaping HTML entities as well.")
+ (license license:expat)))
+
(define-public rust-http-0.2
(package
(name "rust-http")
--
2.34.0
P
P
Pierre Langlois wrote on 18 Feb 2022 15:39
[PATCH v4 03/31] gnu: Add rust-spin@0.7.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220218143948.28989-3-pierre.langlois@gmx.com
* gnu/packages/crates-io.scm (rust-spin-0.7): New variable.
---
gnu/packages/crates-io.scm | 13 +++++++++++++
1 file changed, 13 insertions(+)

Toggle diff (24 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 986901740a..a4bd79607c 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -56726,6 +56726,19 @@ (define-public rust-spin-0.9
initializers are available.")
(license license:expat)))

+(define-public rust-spin-0.7
+ (package
+ (inherit rust-spin-0.9)
+ (name "rust-spin")
+ (version "0.7.1")
+ (source (origin
+ (method url-fetch)
+ (uri (crate-uri "spin" version))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0qjips9f6fsvkyd7wj3a4gzaqknn2q4kkb19957pl86im56pna0k"))))))
+
(define-public rust-spin-0.5
(package
(inherit rust-spin-0.9)
--
2.34.0
P
P
Pierre Langlois wrote on 18 Feb 2022 15:39
[PATCH v4 04/31] gnu: Add tree-sitter.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220218143948.28989-4-pierre.langlois@gmx.com
* gnu/package/tree-sitter.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Register it.
---
gnu/local.mk | 1 +
gnu/packages/tree-sitter.scm | 83 ++++++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 gnu/packages/tree-sitter.scm

Toggle diff (101 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 433467ee39..97ab160c3c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -584,6 +584,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/tmux.scm \
%D%/packages/toolkits.scm \
%D%/packages/tor.scm \
+ %D%/packages/tree-sitter.scm \
%D%/packages/tv.scm \
%D%/packages/uglifyjs.scm \
%D%/packages/uml.scm \
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
new file mode 100644
index 0000000000..10a3a6e57c
--- /dev/null
+++ b/gnu/packages/tree-sitter.scm
@@ -0,0 +1,83 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Pierre Langlois <pierre.langlois@gmx.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages tree-sitter)
+ #:use-module (guix gexp)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix git-download)
+ #:use-module (guix packages)
+ #:use-module (guix utils)
+ #:use-module (gnu packages icu4c))
+
+(define-public tree-sitter
+ (package
+ (name "tree-sitter")
+ (version "0.20.4")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1yldgdbf3l5l4ki52abdf81nwkcbvg219gwr3ydcjwfsg7hf7zhz"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ (delete-file-recursively "lib/src/unicode")))))
+ (inputs
+ (list icu4c))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:tests? #f ;No check target.
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure)
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC"
+ #$(cc-for-target))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out")) (lib (string-append
+ out "/lib")))
+ (setenv "PREFIX" out)
+ (invoke "make" "install")))))))
+ (home-page "https://tree-sitter.github.io/tree-sitter/")
+ (synopsis "Incremental parsing system for programming tools")
+ (description
+ "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @code{libtree-sitter} runtime library.")
+ (license license:expat)))
--
2.34.0
P
P
Pierre Langlois wrote on 18 Feb 2022 15:39
[PATCH v4 05/31] gnu: Add tree-sitter-cli.
(address . 49946@debbugs.gnu.org)(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
20220218143948.28989-5-pierre.langlois@gmx.com
* gnu/packages/tree-sitter.scm (tree-sitter-cli): New variable.
---
gnu/packages/tree-sitter.scm | 66 ++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)

Toggle diff (85 lines)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 10a3a6e57c..cbf8ecdc6c 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -19,10 +19,13 @@
(define-module (gnu packages tree-sitter)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system cargo)
#:use-module (guix build-system gnu)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (gnu packages crates-graphics)
+ #:use-module (gnu packages crates-io)
#:use-module (gnu packages icu4c))

(define-public tree-sitter
@@ -81,3 +84,66 @@ (define-public tree-sitter

This package includes the @code{libtree-sitter} runtime library.")
(license license:expat)))
+
+(define-public tree-sitter-cli
+ (package (inherit tree-sitter)
+ (name "tree-sitter-cli")
+ (build-system cargo-build-system)
+ (arguments
+ `(;; Running test requires downloading fixtures, see the
+ ;; script/fetch-fixtures script.
+ #:tests? #f
+ ;; FIXME: Installing the sources for the tree-sitter Rust bindings
+ ;; doesn't work out of the box due to tree-sitter having multiple
+ ;; Rust packages in the same repository (bindings and CLI).
+ #:install-source? #f
+ #:cargo-inputs
+ (("rust-ansi-term" ,rust-ansi-term-0.12)
+ ("rust-anyhow" ,rust-anyhow-1)
+ ("rust-atty" ,rust-atty-0.2)
+ ("rust-clap" ,rust-clap-2)
+ ("rust-difference" ,rust-difference-2)
+ ("rust-dirs" ,rust-dirs-3)
+ ("rust-html-escape" ,rust-html-escape-0.2)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-rustc-hash" ,rust-rustc-hash-1)
+ ("rust-serde" ,rust-serde-1)
+ ("rust-smallbitvec" ,rust-smallbitvec-2)
+ ("rust-spin" ,rust-spin-0.7)
+ ("rust-thiserror" ,rust-thiserror-1)
+ ("rust-tiny-http" ,rust-tiny-http-0.8)
+ ("rust-toml" ,rust-toml-0.5)
+ ("rust-walkdir" ,rust-walkdir-2)
+ ("rust-webbrowser" ,rust-webbrowser-0.5)
+ ("rust-which" ,rust-which-4))
+ #:cargo-development-inputs
+ (("rust-pretty-assertions" ,rust-pretty-assertions-0.7))
+ #: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)))))))
+ (synopsis "Incremental parsing system for programming tools")
+ (description "Tree-sitter is a parser generator tool and an incremental
+parsing library. It can build a concrete syntax tree for a source file and
+efficiently update the syntax tree as the source file is edited.
+
+Tree-sitter aims to be:
+
+@enumerate
+@item General enough to parse any programming language.
+@item Fast enough to parse on every keystroke in a text editor.
+@item Robust enough to provide useful results even in the presence of syntax
+errors.
+@item Dependency-free so that the runtime library (which is written in pure C)
+can be embedded in any application.
+@end enumerate
+
+This package includes the @command{tree-sitter} command-line tool.")
+ (license license:expat)))
--
2.34.0
P