From 273bd81188c9684d66f972d4d9561cac9fc3f42f Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Sun, 5 Nov 2023 08:55:31 +0200 Subject: 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 --- gnu/packages/rust.scm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'gnu/packages/rust.scm') 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) -- cgit v1.2.3