Add all tree-sitter grammars in Guix

* guix.scm: Add all tree-sitter grammars in Guix repos; move Guile inputs out of
propagated-inputs; cleanup indentation and layout.
* hall.scm: Add all tree-sitter grammars in Guix repos.
This commit is contained in:
Juliana Rat 2023-11-04 15:11:05 -04:00
parent d723e9cd8d
commit 4a7dee2f9e
2 changed files with 173 additions and 61 deletions

197
guix.scm
View file

@ -1,30 +1,29 @@
(use-modules
(guix packages)
((guix licenses) #:prefix license:)
(guix download)
(guix gexp)
(guix build-system gnu)
(gnu packages)
(gnu packages autotools)
(gnu packages guile)
(gnu packages guile-xyz)
(gnu packages pkg-config)
(gnu packages texinfo)
(srfi srfi-1))
(use-modules (gnu packages)
(gnu packages autotools)
(gnu packages guile)
(gnu packages guile-xyz)
(gnu packages pkg-config)
(gnu packages texinfo)
(gnu packages tree-sitter)
(guix build-system gnu)
(guix download)
(guix gexp)
((guix licenses)
#:prefix license:)
(guix packages)
(srfi srfi-1))
(package
(name "sloth")
(version "0.1-dev")
(source
(local-file
(dirname (current-filename))
#:recursive?
#t
#:select?
(λ (file stat)
(not (any (λ (my-string)
(string-contains file my-string))
(list ".git" ".dir-locals.el" "guix.scm"))))))
(local-file
(dirname (current-filename))
#:recursive? #t
#:select? (λ (file stat)
(not (any (λ (my-string)
(string-contains file my-string))
(list ".git" ".dir-locals.el" "guix.scm"))))))
(build-system gnu-build-system)
(arguments
(list
@ -32,54 +31,132 @@
#~(list "GUILE_AUTO_COMPILE=0")
#:phases
#~(modify-phases %standard-phases
(delete 'strip)
(delete 'strip)
(add-before 'configure 'hall-build
(λ _ (system* "hall" "build" "-x")))
(add-after 'hall-build 'autoreconf
(λ _ (system* "autoreconf" "-vif")))
(add-after 'install 'hall-wrap-binaries
(λ _
(use-modules (ice-9 ftw))
(define (compiled-dir out version)
(string-append out "/lib/guile/"
version
"/site-ccache"))
(define (uncompiled-dir out version)
(string-append out
"/share/guile/site"
(if (string-null? version) ""
"/")
version))
(define (dep-path env modules path)
(list env ":"
'prefix
(cons modules
(map (λ (input)
(string-append input path))
(list #$guile-config
#$guile-ncurses
#$guile-ts)))))
(define bin (string-append #$output "/bin/"))
(define site (uncompiled-dir #$output ""))
(define version (caddr (scandir site)))
(wrap-program (string-append bin "sloth")
(dep-path
"GUILE_LOAD_PATH"
(uncompiled-dir #$output version)
(uncompiled-dir "" version))
(dep-path
"GUILE_LOAD_COMPILED_PATH"
(compiled-dir #$output version)
(compiled-dir "" version))))))))
(λ _
(use-modules (ice-9 ftw))
(define (guile-compiled-dir out version)
(string-append out "/lib/guile/"
version
"/site-ccache"))
(define (guile-uncompiled-dir out version)
(string-append out
"/share/guile/site"
(if (string-null? version) ""
"/")
version))
(define (guile-dep-path env modules path)
(list env ":" 'prefix
(cons modules
(map (λ (input)
(string-append input path))
;; TODO: figure out how to put these in a list shared
;; with inputs because DRY
(list #$guile-config
#$guile-ncurses
#$guile-ts)))))
(define bin (string-append #$output "/bin/"))
(define site (guile-uncompiled-dir #$output ""))
(define version (caddr (scandir site)))
(wrap-program (string-append bin "sloth")
(guile-dep-path
"GUILE_LOAD_PATH"
(guile-uncompiled-dir #$output version)
(guile-uncompiled-dir "" version))
(guile-dep-path
"GUILE_LOAD_COMPILED_PATH"
(guile-compiled-dir #$output version)
(guile-compiled-dir "" version))
(list "TREE_SITTER_GRAMMAR_PATH" ":" '=
(map (λ (input)
(string-append input "/lib/tree-sitter"))
;; TODO: figure out how to put these in a list shared
;; with inputs because DRY
(list #$tree-sitter-bash
#$tree-sitter-bibtex
#$tree-sitter-c
#$tree-sitter-c-sharp
#$tree-sitter-clojure
#$tree-sitter-cmake
#$tree-sitter-cpp
#$tree-sitter-css
#$tree-sitter-dockerfile
#$tree-sitter-elixir
#$tree-sitter-elm
#$tree-sitter-go
#$tree-sitter-gomod
#$tree-sitter-haskell
#$tree-sitter-heex
#$tree-sitter-html
#$tree-sitter-java
#$tree-sitter-javascript
#$tree-sitter-json
#$tree-sitter-julia
#$tree-sitter-lua
#$tree-sitter-markdown
#$tree-sitter-markdown-gfm
#$tree-sitter-meson
#$tree-sitter-ocaml
#$tree-sitter-org
#$tree-sitter-php
#$tree-sitter-plantuml
#$tree-sitter-python
#$tree-sitter-r
#$tree-sitter-racket
#$tree-sitter-ruby
#$tree-sitter-rust
#$tree-sitter-scala
#$tree-sitter-scheme
#$tree-sitter-typescript)))))))))
(native-inputs (list autoconf
automake
guile-hall
pkg-config
texinfo))
(inputs (list guile-3.0))
(propagated-inputs (list guile-config
guile-ncurses
guile-ts))
(inputs (list guile-3.0
guile-config
guile-ncurses
guile-ts
tree-sitter-bash
tree-sitter-bibtex
tree-sitter-c
tree-sitter-c-sharp
tree-sitter-clojure
tree-sitter-cmake
tree-sitter-cpp
tree-sitter-css
tree-sitter-dockerfile
tree-sitter-elixir
tree-sitter-elm
tree-sitter-go
tree-sitter-gomod
tree-sitter-haskell
tree-sitter-heex
tree-sitter-html
tree-sitter-java
tree-sitter-javascript
tree-sitter-json
tree-sitter-julia
tree-sitter-lua
tree-sitter-markdown
tree-sitter-markdown-gfm
tree-sitter-meson
tree-sitter-ocaml
tree-sitter-org
tree-sitter-php
tree-sitter-plantuml
tree-sitter-python
tree-sitter-r
tree-sitter-racket
tree-sitter-ruby
tree-sitter-rust
tree-sitter-scala
tree-sitter-scheme
tree-sitter-typescript))
(synopsis "Text editor based on tree-sitter")
(description
"TODO")

View file

@ -12,7 +12,42 @@
(dependencies `(("guile-config" ,guile-config)
("guile-ncurses" ,guile-ncurses)
("guile-ts" ,guile-ts)
("tree-sitter-scheme" ,tree-sitter-scheme)))
("tree-sitter-bash" ,tree-sitter-bash)
("tree-sitter-bibtex" ,tree-sitter-bibtex)
("tree-sitter-c" ,tree-sitter-c)
("tree-sitter-c-sharp" ,tree-sitter-c-sharp)
("tree-sitter-clojure" ,tree-sitter-clojure)
("tree-sitter-cmake" ,tree-sitter-cmake)
("tree-sitter-cpp" ,tree-sitter-cpp)
("tree-sitter-css" ,tree-sitter-css)
("tree-sitter-dockerfile" ,tree-sitter-dockerfile)
("tree-sitter-elixir" ,tree-sitter-elixir)
("tree-sitter-elm" ,tree-sitter-elm)
("tree-sitter-go" ,tree-sitter-go)
("tree-sitter-gomod" ,tree-sitter-gomod)
("tree-sitter-haskell" ,tree-sitter-haskell)
("tree-sitter-heex" ,tree-sitter-heex)
("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-lua" ,tree-sitter-lua)
("tree-sitter-markdown" ,tree-sitter-markdown)
("tree-sitter-markdown-gfm" ,tree-sitter-markdown-gfm)
("tree-sitter-meson" ,tree-sitter-meson)
("tree-sitter-ocaml" ,tree-sitter-ocaml)
("tree-sitter-org" ,tree-sitter-org)
("tree-sitter-php" ,tree-sitter-php)
("tree-sitter-plantuml" ,tree-sitter-plantuml)
("tree-sitter-python" ,tree-sitter-python)
("tree-sitter-r" ,tree-sitter-r)
("tree-sitter-racket" ,tree-sitter-racket)
("tree-sitter-ruby" ,tree-sitter-ruby)
("tree-sitter-rust" ,tree-sitter-rust)
("tree-sitter-scala" ,tree-sitter-scala)
("tree-sitter-scheme" ,tree-sitter-scheme)
("tree-sitter-typescript" ,tree-sitter-typescript)))
(skip ())
(files (libraries
((directory "sloth" ((scheme-file "editor")