1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(define-module (11kb packages tree-sitter)
  #:use-module (guix packages)
  #:use-module (guix build utils)
  #:use-module ((guix utils)
                #:select (substitute-keyword-arguments
                          ensure-keyword-arguments))
  #:use-module ((guix modules)
                #:select (source-module-closure))
  #:use-module (guix gexp)
  #:use-module (gnu packages tree-sitter)
  #:use-module (ice-9 match)
  #:use-module ((guix build-system tree-sitter)
                #:prefix guix-ts:))

(define (package-without-tests p)
    (package/inherit p
      (arguments
       (substitute-keyword-arguments (package-arguments p)
         ((#:tests? _ #f) #f)))))

;; There's a problem with the peerDependencies so we have to remove them.
(define tree-sitter-typst-broken
  (package-without-tests
   ((@@ (gnu packages tree-sitter) tree-sitter-grammar)
    "typst" "Typst"
    "06a3hzmc5xa4vfpfrk77hq9j0n39jxhy450rx2qxisc06bf53zxk"
    "0.12"
    #:commit "46cf4ded12ee974a70bf8457263b67ad7ee0379d"
    #:repository-url "https://github.com/uben0/tree-sitter-typst")))


(define-public tree-sitter-typst
  (package/inherit tree-sitter-typst-broken
    (arguments
     (ensure-keyword-arguments
      (package-arguments tree-sitter-typst-broken)
      (list #:imported-modules
            (cons* '(guix build node-build-system)
                   guix-ts:%tree-sitter-build-system-modules)
            #:modules
            '((guix build utils)
              (guix build tree-sitter-build-system)
              (ice-9 match)
              (guix build node-build-system))
            #:phases
            #~(modify-phases %standard-phases
                (add-after 'patch-dependencies 'patch-peer-dependencies
                  (lambda _
                    (modify-json
                     (delete-dependencies '("tree-sitter")))))))))))