all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Nicholas von Klitzing <nicholas@nvk.pm>
Cc: 52107@debbugs.gnu.org
Subject: bug#52107: An Idea
Date: Fri, 26 Nov 2021 18:07:09 +0000	[thread overview]
Message-ID: <b7417393367c3bc5e0a8f17e6a5b75d7ef74689a.camel@telenet.be> (raw)
In-Reply-To: <SgHNV6OEAv-_PlTS0kF7nq5TiVlY7V8ZmC6QvEUKW8e1BvsBuChDdmbd41fI60Xfc8fvr3ypJUOseRbqMCIORudZIhLKn0WOwBOdwG-ncVk=@nvk.pm>

Nicholas von Klitzing schreef op vr 26-11-2021 om 17:40 [+0000]:
> 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 [...]
>            ;; 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

The package that is using RUST_SRC_PATH is rust-analyzer, not
rust@some-version. As such, the search path should be added to rust-
analyzer, not rust.

Search paths are added to the consumer, not the producer, as I've seen
it described somewhere.

Probably (separator #f) should be added, because I don't think rust-
analyzer supports using source code of multiple rusts at once.

> 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?

The idea is to copy the unpacked source code to some output (let's call
it "source"). We would have to choose some subdirectory. Looking at the
package definition of rust-analyzer, it appears to like
‘lib/rustlib/src/rust’, so the source code could be copied to (string-
append #$output:src "/lib/rustlib/src/rust").

If that directory is used, files would be set to
'("lib/rustlib/src/rust").

> 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))
> ``

Both wrapping and a search path wouldn't make much sense: the wrapping
would effectively override the search path, basically hard-coding the
source code used. Either go for a wrapper, a search path, or a wrapper
only setting the environment variable if it wasn't set already (*)(such
that the wrapper only sets a default).

(*) see docstring of wrap-program for how to do this, and whether it is
actually possible.

If you go for a wrapper instead of native-search-path, then
RUST_SRC_PATH would be unset in the build environment, so the (getenv
...) would need to be replaced with (search-input-directory (or native-
inputs inputs) "lib/rustlib/src/rust")).

Greetings,
Maxime






      reply	other threads:[~2021-11-26 18:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 14:53 bug#52107: rust-analyzer shipped broken without rust-src Nicholas von Klitzing
2021-11-26  9:42 ` bug#52107: An Idea Nicholas von Klitzing
2021-11-26 14:21   ` Maxime Devos
2021-11-26 17:40     ` Nicholas von Klitzing
2021-11-26 18:07       ` Maxime Devos [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7417393367c3bc5e0a8f17e6a5b75d7ef74689a.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=52107@debbugs.gnu.org \
    --cc=nicholas@nvk.pm \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.