aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/rust.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2023-10-01 19:48:59 +0300
committerEfraim Flashner <efraim@flashner.co.il>2023-10-18 11:35:53 +0300
commit020aca2a1f5720f9ebe45a6c389e2567d15b3885 (patch)
treeca7a1dedb1583429705bdc9a4ffc54c28ff322a5 /gnu/packages/rust.scm
parent5f10c3551bc0c136a4732925c2e26f895c26422a (diff)
downloadguix-020aca2a1f5720f9ebe45a6c389e2567d15b3885.tar
guix-020aca2a1f5720f9ebe45a6c389e2567d15b3885.tar.gz
gnu: rust: Wrap rust-analyzer with rust source.
* gnu/packages/rust.scm (rust)[outputs]: Add rust-src output. [arguments]: Add a phase to install the rust sources and a phase to wrap the rust-analyzer binary with the path to the rust sources.
Diffstat (limited to 'gnu/packages/rust.scm')
-rw-r--r--gnu/packages/rust.scm18
1 files changed, 16 insertions, 2 deletions
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 34511f283e..0dc60c8991 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -760,7 +760,7 @@ safety and thread safety guarantees.")
(let ((base-rust rust-1.70))
(package
(inherit base-rust)
- (outputs (cons "tools" (package-outputs base-rust)))
+ (outputs (cons* "rust-src" "tools" (package-outputs base-rust)))
(arguments
(substitute-keyword-arguments (package-arguments base-rust)
((#:tests? _ #f)
@@ -919,7 +919,21 @@ safety and thread safety guarantees.")
(format #f "prefix = ~s" (assoc-ref outputs "tools"))))
(invoke "./x.py" "install" "clippy")
(invoke "./x.py" "install" "rust-analyzer")
- (invoke "./x.py" "install" "rustfmt")))))))
+ (invoke "./x.py" "install" "rustfmt")))
+ (add-after 'install 'install-rust-src
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "rust-src"))
+ (dest "/lib/rustlib/src/rust"))
+ (mkdir-p (string-append out dest))
+ (copy-recursively "library" (string-append out dest "/library"))
+ (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"))))))))))
;; Add test inputs.
(native-inputs (cons* `("gdb" ,gdb/pinned)
`("procps" ,procps)