That's definitely a much better solution.
I'm having trouble finding documentation about both native-search-paths and wrap-program, so let me know if I understand your suggestions and how to apply them correctly.
The rust-1.18 package has a native-search-paths declaration:
``
(native-search-paths
(list (search-path-specification
(variable "C_INCLUDE_PATH")
(files '("include")))
(search-path-specification
(variable "CPLUS_INCLUDE_PATH")
(files '("include/c++" "include")))
(search-path-specification
(variable "LIBRARY_PATH")
(files '("lib" "lib64")))
;; Do you mean add something along the lines of
;; this to every rust-xx package?
(search-path-specification
(variable "RUST_SRC_PATH")
(files '("library"))))) ;; I'm not sure what arguments this takes
``
The directory structure of the rust repository, changes over time, so the paths would need to be adjusted depending on the version. Would I also need to add an additional build step to copy over the source and register it as an output?
And for the rust-analyzer package we then add something along the lines of?
``
(add-after
'install 'wrap-rust-analyzer
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(rust-src-path (getenv "RUST_SRC_PATH")))
(wrap-program (string-append out "/bin/rust-analyzer")
`("RUST_SRC_PATH" ":" prefix (,rust-src-path))))
#t))
``
I'd appreciate your feedback, since I'm mostly clueless :)
Kind regards,
Nicholas
??????? Original Message ???????
On Friday, November 26th, 2021 at 2:21 PM, Maxime Devos <maximedevos@telenet.be> wrote:
Toggle quote (43 lines)
> Nicholas von Klitzing schreef op vr 26-11-2021 om 09:42 [+0000]:
>
> > Just to get the ball rolling, here is a possible idea.
> >
> > It might makes sense to add an additional output to the rust package
> >
> > `src` and then require this by the rust-analyzer package as
> >
> > `rust:src`.
>
> I'd use a native-search-path instead of a wrapper setting the
>
> environment variable, such that rust-analyzer can be used with any
>
> version of rust and the user can override the source code used.
>
> > In the rust-analyzer package we could then copy a thing from
> >
> > `icedove-wayland`:
> >
> > [
> >
> > ...] (call-with-output-file exe
> >
> > (lambda (port)
> >
> > (format port "#!~a
> >
> > ;; This style of overriding environment variables could be used for
> >
> > ;; RUST_SRC_PATH, although I am not sure if this is the idiomatic
> >
> > ;; way to do it.
> >
> > MOZ_ENABLE_WAYLAND=1 exec ~a $@"
>
> 'wrap-program' could be used here, instead of manually making shell
>
> scripts.
>
> Greetings,
>
> Maxime