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: (
Subject: Re: Howto supply cargo-build-system dependency to guix package definition
Date: Fri, 28 Apr 2023 15:23:53 +0100

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]