~whereiseveryone/guixrus

guixrus/guixrus/packages/helix.scm -rw-r--r-- 7.4 KiB
e23458a3jgart add emacs-consult-lsp 11 hours ago
                                                                                
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
;;;
;;; This file is not 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 (guixrus packages helix)
  #:use-module (guix build-system cargo)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (gnu packages crates-io)
  #:use-module (guixrus packages common rust)
  #:use-module (guixrus packages tree-sitter))

;;; XXX This package pulls in unauditable blobs; namely, the generated Tree-sitter C
;;; programs. This should be fixable by adding the tree-sitter grammars themselves to
;;; Guix and copying the output files into Helix's runtime directory.
(define-public helix
  (let ((commit "d11b6521399f41cb4c0b75ebaa5770972f550ebb")
        (revision "0"))
    (package
     (name "helix")
     (version (git-version "0.6.0" revision commit))
     (source
      (origin
       (method git-fetch)
       (uri (git-reference
             (commit commit)
             (url "https://github.com/helix-editor/helix")
             ;; Helix pulls in Tree-sitter grammars in its submodules.
             (recursive? #t)))
       (sha256
        (base32 "1xpa8zf7abwri6wyxb90nvqi3sqjkvmy7dllxairv07x6csrvsgi"))))
     (build-system cargo-build-system)
     (arguments
      `(;; XXX tests fail
        #:tests? #f
        #:cargo-inputs
        (("rust-anyhow" ,rust-anyhow-1)
         ("rust-arc-swap" ,rust-arc-swap-1)
         ("rust-autocfg" ,rust-autocfg-1)
         ("rust-bitflags" ,rust-bitflags-1)
         ("rust-cassowary" ,rust-cassowary-0.3)
         ("rust-cc" ,rust-cc-1)
         ("rust-chardetng" ,rust-chardetng-0.1)
         ("rust-chrono" ,rust-chrono-0.4)
         ("rust-clipboard-win" ,rust-clipboard-win-4)
         ("rust-content-inspector" ,rust-content-inspector-0.2)
         ("rust-crossterm" ,rust-crossterm-0.23)
         ("rust-encoding" ,rust-encoding-rs-0.8)
         ("rust-etcetera" ,rust-etcetera-0.3)
         ("rust-futures-executor" ,rust-futures-executor-0.3)
         ("rust-futures-util" ,rust-futures-util-0.3)
         ("rust-fuzzy-matcher" ,rust-fuzzy-matcher-0.3)
         ("rust-grep-regex" ,rust-grep-regex-0.1)
         ("rust-grep-searcher" ,rust-grep-searcher-0.1)
         ("rust-ignore" ,rust-ignore-0.4)
         ("rust-jsonrpc-core" ,rust-jsonrpc-core-18)
         ("rust-libloading" ,rust-libloading-0.7)
         ("rust-log" ,rust-log-0.4)
         ("rust-lsp-types" ,rust-lsp-types-0.92)
         ("rust-num-cpus" ,rust-num-cpus-1)
         ("rust-once-cell" ,rust-once-cell-1)
         ("rust-pulldown-cmark" ,rust-pulldown-cmark-0.9)
         ("rust-regex" ,rust-regex-1)
         ("rust-ropey" ,rust-ropey-1)
         ("rust-serde" ,rust-serde-1)
         ("rust-serde-json" ,rust-serde-json-1)
         ("rust-signal-hook" ,rust-signal-hook-0.3)
         ("rust-signal-hook-tokio" ,rust-signal-hook-tokio-0.3)
         ("rust-similar" ,rust-similar-2)
         ("rust-slotmap" ,rust-slotmap-1)
         ("rust-smallvec" ,rust-smallvec-1)
         ("rust-smartstring" ,rust-smartstring-0.2)
         ("rust-thiserror" ,rust-thiserror-1)
         ("rust-threadpool" ,rust-threadpool-1)
         ("rust-tokio" ,rust-tokio-1)
         ("rust-tokio-stream" ,rust-tokio-stream-0.1)
         ("rust-toml" ,rust-toml-0.5)
         ("rust-tree-sitter" ,rust-tree-sitter-0.20)
         ("rust-unicode-general-category" ,rust-unicode-general-category-0.5)
         ("rust-unicode-segmentation" ,rust-unicode-segmentation-1)
         ("rust-unicode-width" ,rust-unicode-width-0.1)
         ("rust-url" ,rust-url-2)
         ("rust-which" ,rust-which-4))
        #:cargo-development-inputs
        (("rust-fern" ,rust-fern-0.6)
         ("rust-quickcheck" ,rust-quickcheck-1))
        #:phases
        (modify-phases %standard-phases
        #;
          (add-after 'unpack 'patch-helix-term
            (lambda _
              (substitute* "helix-term/Cargo.toml"
                (("tui = \\{ path = \"../helix-tui\", package = \"helix-tui\", default-features = false, features = \\[\"crossterm\"\\] \\}")
                 "tui = { version = \"*\", path = \"../helix-tui\", package = \"helix-tui\", default-features = false, features = [\"crossterm\"] }"))))
          (add-after 'unpack 'remove-yaml-test-suite
            (lambda _
              (delete-file-recursively "helix-syntax/languages/tree-sitter-yaml/yaml-test-suite")))
          (replace 'install
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (install-file "target/release/hx" (string-append out "/bin")))))
          (add-before 'package 'patch-cargo.tomls
            (lambda _
              (substitute* "helix-dap/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "helix-lsp/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "helix-syntax/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "helix-term/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "helix-tui/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "helix-view/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "xtask/Cargo.toml"
                (("helix-(.*) = \\{ version = \"(.*)\", path = \"../helix-(.*)\" \\}" _ pkg-name)
                 ""))
              (substitute* "helix-term/Cargo.toml"
                (("tui = .*\n")
                 ""))))
          (add-after 'install 'install-runtime
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (copy-recursively "runtime" (string-append out "/usr/share/helix/runtime")))))
          (add-after 'install-runtime 'patch-runtime-env-var
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (wrap-program (string-append out "/bin/hx")
                  `("HELIX_RUNTIME" = (,(string-append out "/usr/share/helix/runtime"))))))))))
     (home-page "https://helix-editor.com")
     (synopsis "A post-modern text editor.")
     (description "Helix is a modal terminal-based text editor inspired by
Neovim and Kakoune, with modern features like LSP included by default.")
     (license license:mpl2.0))))