help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Howto supply cargo-build-system dependency to guix package definitio


From: Timothy Washington
Subject: Re: Howto supply cargo-build-system dependency to guix package definition
Date: Fri, 28 Apr 2023 16:08:45 -0400

Beauutiful!

A. Actually the "guix import crate" command set off a light bulb... Can't I
just pull in those dependencies recursively. And indeed you can. The only
reason I needed to pull in those crates, were as dependencies to rustscan
<https://crates.io/crates/rustscan>. So I went back to the beginning and
ran a recursive import on rustscan.

$ guix import crate -r rustscan
...

$ guix build -L ~/dotfiles/ rust-rustscan-2

phase `check' succeeded after 0.0 seconds
starting phase `install'
  Installing rustscan v2.1.1
(/tmp/guix-build-rust-rustscan-2.1.1.drv-0/rustscan-2.1.1)
    Finished release [optimized] target(s) in 0.19s
  Installing
/gnu/store/10sivvy746n5jdnsgny5afxpwa5yzy5f-rust-rustscan-2.1.1/bin/rustscan
   Installed package `rustscan v2.1.1
(/tmp/guix-build-rust-rustscan-2.1.1.drv-0/rustscan-2.1.1)` (executable
`rustscan`)
warning: be sure to add
`/gnu/store/10sivvy746n5jdnsgny5afxpwa5yzy5f-rust-rustscan-2.1.1/bin` to
your PATH to be able to run the
...
successfully built
/gnu/store/58bdgq64bdxkhwjvfmragj4xq8h7grhb-rust-rustscan-2.1.1.drv
/gnu/store/10sivvy746n5jdnsgny5afxpwa5yzy5f-rust-rustscan-2.1.1


B. Should I supply this to an upstream configuration? Or should each user
run their own "guix import"?
I'm happy to supply this as a definition if need be.

And thanks again!
Tim


On Fri, 28 Apr 2023 at 10:31, ( <paren@disroot.org> wrote:

> Timothy Washington <twashing@gmail.com> writes:
> > ..the build fails on missing "cidr-utils". Now "cidr-utils" is in Rust's
> crates.io.
> > But is that what Guix' cargo-build-system is referencing?
> > Otherwise, do we need to create a Guix .scm (scheme definition)?
>
> Guix can't grab things from the internet during the build for
> reproducibility reasons, so it uses a Cargo feature that lets you
> substitute the registry for a directory full of tarballed crates, and
> unpacks all the CARGO-INPUTS there (this is why CARGO-BUILD-SYSTEM uses
> its own input list rather than just INPUTS).
>
> It seems like Guix doesn't have RUST-CIDR-UTILS yet:
>
> ```
> $ guix show rust-cidr-utils
> guix show: error: rust-cidr-utils: package not found
> ```
>
> You don't have to write the package definition manually, though:
>
> ```
> $ guix import crate cidr-utils
> (define-public rust-cidr-utils-0.5
>   (package
>     (name "rust-cidr-utils")
>     (version "0.5.10")
>     (source (origin
>               (method url-fetch)
>               (uri (crate-uri "cidr-utils" version))
>               (file-name (string-append name "-" version ".tar.gz"))
>               (sha256
>                (base32
>                 "0750jbxvdbyyxcqnzsw438158r9drs2g077ymx9r9lv193q3dypx"))))
>     (build-system cargo-build-system)
>     (arguments
>      `(#:cargo-inputs (("rust-debug-helper" ,rust-debug-helper-0.3)
>                        ("rust-num-bigint" ,rust-num-bigint-0.4)
>                        ("rust-num-traits" ,rust-num-traits-0.2)
>                        ("rust-once-cell" ,rust-once-cell-1)
>                        ("rust-regex" ,rust-regex-1)
>                        ("rust-serde" ,rust-serde-1))))
>     (home-page "https://magiclen.org/cidr-utils";)
>     (synopsis
>      "This crate provides data structures and functions to deal with IPv4
> CIDRs and IPv6 CIDRs.")
>     (description
>      "This crate provides data structures and functions to deal with IPv4
> CIDRs and
> IPv6 CIDRs.")
>     (license license:expat)))
> ```
>
> Above your main package definition, you should copy in this package, and
> you'll want to edit the SYNOPSIS and DESCRIPTION to make them less alike
> and make them follow the usual style:
>
> ```
> (synopsis "CIDR library for IPv4 and IPv6")
> (description
>  "This package provides a crate for dealing with Classless Inter-Domain
> Routing in IPv4 and IPv6.")
> ```
>
> Now you can just use RUST-CIDR-UTILS-0.5 like any other crate.
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]