(define-module (ruther packages vhdl-ls)
#:use-module (ruther packages rust-crates)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix utils)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix download)
#:use-module (guix build-system cargo)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages crates-windows))
(define-public vhdl-ls
(package
(name "vhdl-ls")
(version "0.83.1")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/VHDL-LS/rust_hdl")
(commit (string-append "v" version))))
;; (snippet
;; #~(begin (use-modules (guix build utils))
;; (substitute* "vhdl_ls/Cargo.toml"
;; ((", path = \"../vhdl_lang\"") ""))))
(sha256
(base32 "0fs8qghnxw82by8dmlxlvm2spzqq3rk8aywj1ay7jxzwblkpkvq0"))))
(build-system cargo-build-system)
(native-inputs
(list
))
(inputs
(my-cargo-inputs 'vhdl-ls))
(arguments
(list
#:phases
#~(modify-phases %standard-phases
(add-after 'install 'install-libraries
(lambda _
(mkdir-p (string-append #$output "/share/vhdl_libraries"))
(copy-recursively "vhdl_libraries"
(string-append #$output "/share/vhdl_libraries"))))
(replace 'package
(lambda _
(begin
;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source
(when (file-exists? "Cargo.toml.orig")
(delete-file "Cargo.toml.orig"))
;; Use unstable feature ‘--registry’.
(setenv "RUSTC_BOOTSTRAP" "1")
(for-each
(lambda (pkg)
(invoke "cargo" "package" "--offline" "--package" pkg
"--registry" "crates-io" "-Z" "package-workspace"
"--no-metadata" "--no-verify")
(for-each
(lambda (crate)
(invoke "tar" "xzf" crate "-C" "guix-vendor"))
(begin
(delete-file-recursively "target/package/tmp-registry")
(find-files "target/package" "\\.crate$")))
((assoc-ref %standard-phases 'patch-cargo-checksums)))
'("vhdl_lang_macros" "vhdl_lang" "vhdl_ls"))
(unsetenv "RUSTC_BOOTSTRAP"))))
(replace 'install
(lambda _
(mkdir-p #$output)
(invoke "cargo" "install" "--no-track"
"--path" "./vhdl_ls" "--root" #$output))))
;; TODO After rust-team gets merged, remove replacement of 'package and use this
;; #:cargo-package-crates ''("vhdl_lang_macros" "vhdl_lang" "vhdl_ls")
;; TODO After rust-team gets merged, remove replacement of 'install and use this
;; #:cargo-install-paths ''("vhdl_ls")
#:cargo-test-flags
'(list
"--release"
"--package" "vhdl_ls")
))
(home-page "https://github.com/kraigher/rust_hdl")
(synopsis "VHDL Language Server")
(description "This package provides VHDL Language Server.")
(license license:mpl2.0)))