aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/rust.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2023-11-05 08:55:31 +0200
committerEfraim Flashner <efraim@flashner.co.il>2023-11-28 07:59:22 +0200
commit273bd81188c9684d66f972d4d9561cac9fc3f42f (patch)
treec8f82dfbbe0a574760e1aa9b97197eae7458837a /gnu/packages/rust.scm
parent4b0fcbd00a67a9adae79e1f838cebe8d74e4d734 (diff)
downloadguix-273bd81188c9684d66f972d4d9561cac9fc3f42f.tar
guix-273bd81188c9684d66f972d4d9561cac9fc3f42f.tar.gz
gnu: rust: Allow using custom rust-src for rust-analyzer.
* gnu/packages/rust.scm (rust)[arguments]: Rewrite 'wrap-rust-analyzer phase to allow using a custom RUST_SRC_PATH. Change-Id: Id811bc8d09c0f955ece9c9e6267a0ae96e61f105
Diffstat (limited to 'gnu/packages/rust.scm')
-rw-r--r--gnu/packages/rust.scm18
1 files changed, 13 insertions, 5 deletions
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 87bd578e9e..e11148e89e 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1030,11 +1030,19 @@ safety and thread safety guarantees.")
(copy-recursively "src" (string-append out dest "/src")))))
(add-after 'install-rust-src 'wrap-rust-analyzer
(lambda* (#:key outputs #:allow-other-keys)
- (wrap-program (string-append (assoc-ref outputs "tools")
- "/bin/rust-analyzer")
- `("RUST_SRC_PATH" ":" =
- (,(string-append (assoc-ref outputs "rust-src")
- "/lib/rustlib/src/rust/library"))))))))))
+ (let ((bin (string-append (assoc-ref outputs "tools") "/bin")))
+ (rename-file (string-append bin "/rust-analyzer")
+ (string-append bin "/.rust-analyzer-real"))
+ (call-with-output-file (string-append bin "/rust-analyzer")
+ (lambda (port)
+ (format port "#!~a
+if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi;
+exec -a \"$0\" \"~a\" \"$@\""
+ (which "bash")
+ (string-append (assoc-ref outputs "rust-src")
+ "/lib/rustlib/src/rust/library")
+ (string-append bin "/.rust-analyzer-real"))))
+ (chmod (string-append bin "/rust-analyzer") #o755))))))))
;; Add test inputs.
(native-inputs (cons* `("gdb" ,gdb/pinned)
`("procps" ,procps)