unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Rust Packaging without crates.io
@ 2022-08-24  1:38 Jonathan Scoresby
  2022-08-24 16:06 ` (
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Scoresby @ 2022-08-24  1:38 UTC (permalink / raw)
  To: help-guix

I am trying to build a package definition for a rust project that is not on crates.io (package A). It has a dependency for another rust project that is also not hosted on crates.io (package B). How do I get guix to reference the guix package B instead of trying to fetch it from the source repository?

I'm new to guix but I took a look into the build system code, and it seems like guix just changes the crates.io source to a local repository, but this doesn't work with packages that are hosted outside crates.io.

Would it be best to modify the cargo.toml to not reference a git repo? Or is there a better way? Assuming I do that, how do I ensure that package B still ends up in the guix-vendor directory during the build?

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24  1:38 Rust Packaging without crates.io Jonathan Scoresby
@ 2022-08-24 16:06 ` (
  2022-08-24 16:23   ` Jonathan Scoresby
  0 siblings, 1 reply; 10+ messages in thread
From: ( @ 2022-08-24 16:06 UTC (permalink / raw)
  To: Jonathan Scoresby, help-guix

Hi Jonathon,

You can just write a normal package for a crate on Git, replacing the source with
something like:

  (origin
    (method git-fetch)
    (uri (git-reference
          (url "...")
          (commit (string-append "v" version))))
    (file-name (git-file-name name version))
    (sha256
     (base32
      "...")))

You can use a Rust package built like this in the same way as a normal crates.io
crate. Just add it to cargo-inputs or cargo-development-inputs as appropriate :)

    -- (


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 16:06 ` (
@ 2022-08-24 16:23   ` Jonathan Scoresby
  2022-08-24 16:29     ` (
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Scoresby @ 2022-08-24 16:23 UTC (permalink / raw)
  To: (, help-guix


> On 08/24/2022 10:06 MDT ( <paren@disroot.org> wrote:
> 
>  
> Hi Jonathon,
> 
> You can just write a normal package for a crate on Git, replacing the source with
> something like:
> 
>   (origin
>     (method git-fetch)
>     (uri (git-reference
>           (url "...")
>           (commit (string-append "v" version))))
>     (file-name (git-file-name name version))
>     (sha256
>      (base32
>       "...")))
> 
> You can use a Rust package built like this in the same way as a normal crates.io
> crate. Just add it to cargo-inputs or cargo-development-inputs as appropriate :)
> 
>     -- (


Thank you for the reply. This is what I have done. The problem I am having is that when I do this, cargo is not referencing it properly. The Cargo.toml file will have a line like:

package = {git=url, rev=commit}

I have successfully packaged the package it is referencing in the fashion you have shown and have provided it under cargo-inputs, but cargo is still trying to find the package at the git url.

-Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 16:23   ` Jonathan Scoresby
@ 2022-08-24 16:29     ` (
  2022-08-24 16:52       ` Jonathan Scoresby
  0 siblings, 1 reply; 10+ messages in thread
From: ( @ 2022-08-24 16:29 UTC (permalink / raw)
  To: Jonathan Scoresby, help-guix

Ah, I think this is because Cargo's vendor directory feature substitutes
a directory specifically for the crates.io registry. Since only a Git
dependency is specified, it doesn't even bother looking in the directory.
Just patch the line in the crates.io file to say something like:

  pkg = "*"

    -- (


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 16:29     ` (
@ 2022-08-24 16:52       ` Jonathan Scoresby
  2022-08-24 16:56         ` (
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Scoresby @ 2022-08-24 16:52 UTC (permalink / raw)
  To: (, help-guix

Yes. That is what I was trying to expalain. I will try that out, though I must say that this solution feels a little bit hacky. Shouldn't guix be checking somehow that the referenced package is correct?

-Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 16:52       ` Jonathan Scoresby
@ 2022-08-24 16:56         ` (
  2022-08-24 17:05           ` Jonathan Scoresby
  0 siblings, 1 reply; 10+ messages in thread
From: ( @ 2022-08-24 16:56 UTC (permalink / raw)
  To: Jonathan Scoresby, help-guix

Not entirely sure what you mean by "checking if it's correct", but
the entire cargo-build-system is something of a hack. That will
change with antioxidant-build-system, hopefully coming soon to a
core-updates near you™. :)

    -- (


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 16:56         ` (
@ 2022-08-24 17:05           ` Jonathan Scoresby
  2022-08-24 17:08             ` (
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Scoresby @ 2022-08-24 17:05 UTC (permalink / raw)
  To: (; +Cc: help-guix

I mean that the referenced package could be anything. I feel like guix should somehow verify that the referenced package was built from the source specified in the cargo.toml.

Also, it does not check the version. If the main package changed to depend on a newer version, the suggested more of creating a package definition would allow one to build the new package using the outdated dependency.

Anywhere I can read about antioxidant?

-Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 17:05           ` Jonathan Scoresby
@ 2022-08-24 17:08             ` (
  2022-08-24 17:11               ` Jonathan Scoresby
  0 siblings, 1 reply; 10+ messages in thread
From: ( @ 2022-08-24 17:08 UTC (permalink / raw)
  To: Jonathan Scoresby; +Cc: help-guix

On Wed Aug 24, 2022 at 6:05 PM BST, Jonathan Scoresby wrote:
> Also, it does not check the version. If the main package changed to depend on a newer version, the suggested more of creating a package definition would allow one to build the new package using the outdated dependency.

You could add a version constraint to it if you like; what's the version
in the dependency's cargo.toml?

> Anywhere I can read about antioxidant?

Courtesy of Maxime Devos: <https://notabug.org/maximed/cargoless-rust-experiments>

    -- (


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 17:08             ` (
@ 2022-08-24 17:11               ` Jonathan Scoresby
  2022-08-24 17:12                 ` (
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Scoresby @ 2022-08-24 17:11 UTC (permalink / raw)
  To: (; +Cc: help-guix


> On 08/24/2022 11:08 MDT ( <paren@disroot.org> wrote:
>
> You could add a version constraint to it if you like; what's the version
> in the dependency's cargo.toml?

It's rev={commit}

-Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Rust Packaging without crates.io
  2022-08-24 17:11               ` Jonathan Scoresby
@ 2022-08-24 17:12                 ` (
  0 siblings, 0 replies; 10+ messages in thread
From: ( @ 2022-08-24 17:12 UTC (permalink / raw)
  To: Jonathan Scoresby; +Cc: help-guix

On Wed Aug 24, 2022 at 6:11 PM BST, Jonathan Scoresby wrote:
> It's rev={commit}

Try visiting that commit in the dep's repo and see what version it's at,
then use an appropriate semver spec instead of `*`.

    -- (


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-08-24 17:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24  1:38 Rust Packaging without crates.io Jonathan Scoresby
2022-08-24 16:06 ` (
2022-08-24 16:23   ` Jonathan Scoresby
2022-08-24 16:29     ` (
2022-08-24 16:52       ` Jonathan Scoresby
2022-08-24 16:56         ` (
2022-08-24 17:05           ` Jonathan Scoresby
2022-08-24 17:08             ` (
2022-08-24 17:11               ` Jonathan Scoresby
2022-08-24 17:12                 ` (

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).