all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Howto supply cargo-build-system dependency to guix package definition
@ 2023-04-23 16:18 Timothy Washington
  2023-04-24  6:19 ` (
  0 siblings, 1 reply; 12+ messages in thread
From: Timothy Washington @ 2023-04-23 16:18 UTC (permalink / raw)
  To: help-guix

Heyyo, I'm new to Guix packaging here. And am trying to build RustScan
<https://github.com/RustScan/RustScan> as a Guix package.
This is my definition, which uses the "cargo-build-system".

(define-module (guix packages tmp rustscan)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system cargo)
  #:use-module (guix licenses))


(define-public rustscan
  (package
    (name "rustscan")
    (version "2.1.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/RustScan/RustScan.git")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
"042jb4psvs6fj0abxsamza8rnbmc6r7yxygg42q6qjyl8cp2k6rk"))))
    (build-system cargo-build-system)
    (native-inputs
     `(("rustc" ,rustc)
       ("cargo" ,cargo)))
    (inputs
     `(("ansi_term" ,ansi-term)))
    (arguments
     `(#:cargo-inputs
       (("ansi-term" ,ansi-term))))
    (home-page "https://github.com/RustScan/RustScan")
    (synopsis "A fast port scanner written in Rust")
    (description "RustScan is a fast port scanner that utilizes the Rust
programming language to scan for open ports on IP addresses.")
    (license gpl3+)))


However, I'm getting this failure when I try to build. Basically it can't
find a reference to the ansi-term dependency
<https://github.com/RustScan/RustScan/blob/master/Cargo.toml#L32>.

guix build -L ~/dotfiles/ rustscan
ice-9/eval.scm:223:20: In procedure proc:
error: ansi-term: unbound variable
hint: Did you forget a `use-modules' form?


How do you supply the "ansi-term" Cargo dependency
<https://docs.rs/ansi_term/0.12.1/ansi_term/>, to this guix package
definition?


Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>
(647) 283-2856

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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-23 16:18 Howto supply cargo-build-system dependency to guix package definition Timothy Washington
@ 2023-04-24  6:19 ` (
  2023-04-24  6:23   ` (
  0 siblings, 1 reply; 12+ messages in thread
From: ( @ 2023-04-24  6:19 UTC (permalink / raw)
  To: Timothy Washington; +Cc: help-guix

Timothy Washington <twashing@gmail.com> writes:
>     (native-inputs
>      `(("rustc" ,rustc)
>        ("cargo" ,cargo)))
>     (inputs
>      `(("ansi_term" ,ansi-term)))
You don't need these.

>     (arguments
>      `(#:cargo-inputs
>        (("ansi-term" ,ansi-term))))

Try this:

```
    (arguments
     (list #:cargo-inputs
           #~`(("rust-ansi-term" ,rust-ansi-term-0.12))))
```


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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-24  6:19 ` (
@ 2023-04-24  6:23   ` (
  2023-04-25  3:48     ` Timothy Washington
  0 siblings, 1 reply; 12+ messages in thread
From: ( @ 2023-04-24  6:23 UTC (permalink / raw)
  To: (; +Cc: Timothy Washington, help-guix

"(" <paren@disroot.org> writes:
> Timothy Washington <twashing@gmail.com> writes:
>>     (native-inputs
>>      `(("rustc" ,rustc)
>>        ("cargo" ,cargo)))
>>     (inputs
>>      `(("ansi_term" ,ansi-term)))
> You don't need these.
>
>>     (arguments
>>      `(#:cargo-inputs
>>        (("ansi-term" ,ansi-term))))
>
> Try this:
>
> ```
>     (arguments
>      (list #:cargo-inputs
>            #~`(("rust-ansi-term" ,rust-ansi-term-0.12))))
> ```

(You'll need to import (guix gexp) and (gnu packages cargo-xyz) for this
to work.)



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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-24  6:23   ` (
@ 2023-04-25  3:48     ` Timothy Washington
  2023-04-25  5:56       ` (
  0 siblings, 1 reply; 12+ messages in thread
From: Timothy Washington @ 2023-04-25  3:48 UTC (permalink / raw)
  To: (; +Cc: help-guix

You've gotten me quite a bit further. This is great.
Now, "guix build ..." breaks if I try to include "(gnu packages cargo-xyz)"
(*or "(guix packages cargo-xyz)"*).

A.
guix build -L ~/dotfiles/ rustscan
...
no code for module (gnu packages cargo-xyz)


B. And I don't see cargo-xyz in these locations.

   - https://packages.guix.gnu.org/search/?query=cargo-xyz
   - https://packages.guix.gnu.org/search/?query=cargo
   - https://packages.guix.gnu.org/search/?query=xyz


C.
I disabled cargo-xyz and included "crates-graphics" to no avail. Is it
having a problem with "rust-ansi-term-0.12"? Because I definitely see it
here.
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/crates-graphics.scm#n137

guix build -L ~/dotfiles/ rustscan
...
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure append: Wrong type argument in position 1 (expecting empty
list): #<gexp (quasiquote (("rust-ansi-term" (unquote
rust-ansi-term-0.12))))
/home/twashing/dotfiles/guix/packages/rustscan.scm:26:10 7f8a484722d0>


D.
(define-module (guix packages rustscan)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system cargo)
  #:use-module (guix gexp)
  #:use-module (gnu packages crates-graphics)  ;; << enabled
  ;; #:use-module (gnu packages cargo-xyz)  ;; << disabled
  #:use-module (guix licenses))

(define-public rustscan
  (package
   (name "rustscan")
   (version "2.1.1")
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/RustScan/RustScan.git")
                  (commit version)))
            (file-name (git-file-name name version))
            (sha256
             (base32
"1hs065rrk40ksbxh413fbgnr760adgw9dlg5qqv6xb04ra0n0hjf"))))
   (build-system cargo-build-system)
   (arguments
    (list #:cargo-inputs
          #~`(("rust-ansi-term" ,rust-ansi-term-0.12))))
   (home-page "https://github.com/RustScan/RustScan")
   (synopsis "A fast port scanner written in Rust")
   (description "RustScan is a fast port scanner that utilizes the Rust
programming language to scan for open ports on IP addresses.")
   (license gpl3+)))



On Mon, 24 Apr 2023 at 02:24, ( <paren@disroot.org> wrote:

> "(" <paren@disroot.org> writes:
> > Timothy Washington <twashing@gmail.com> writes:
> >>     (native-inputs
> >>      `(("rustc" ,rustc)
> >>        ("cargo" ,cargo)))
> >>     (inputs
> >>      `(("ansi_term" ,ansi-term)))
> > You don't need these.
> >
> >>     (arguments
> >>      `(#:cargo-inputs
> >>        (("ansi-term" ,ansi-term))))
> >
> > Try this:
> >
> > ```
> >     (arguments
> >      (list #:cargo-inputs
> >            #~`(("rust-ansi-term" ,rust-ansi-term-0.12))))
> > ```
>
> (You'll need to import (guix gexp) and (gnu packages cargo-xyz) for this
> to work.)
>
>

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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-25  3:48     ` Timothy Washington
@ 2023-04-25  5:56       ` (
  2023-04-25 20:44         ` Timothy Washington
  0 siblings, 1 reply; 12+ messages in thread
From: ( @ 2023-04-25  5:56 UTC (permalink / raw)
  To: Timothy Washington; +Cc: help-guix

Timothy Washington <twashing@gmail.com> writes:
> You've gotten me quite a bit further. This is great. 
> Now, "guix build ..." breaks if I try to include "(gnu packages cargo-xyz)" (or "(guix packages cargo-xyz)"). 

My mistake, it's actually ``crates-xyz'' :P


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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-25  5:56       ` (
@ 2023-04-25 20:44         ` Timothy Washington
  2023-04-26  5:43           ` (
  0 siblings, 1 reply; 12+ messages in thread
From: Timothy Washington @ 2023-04-25 20:44 UTC (permalink / raw)
  To: (; +Cc: help-guix

On Tue, 25 Apr 2023 at 01:57, ( <paren@disroot.org> wrote:

> Timothy Washington <twashing@gmail.com> writes:
> > You've gotten me quite a bit further. This is great.
> > Now, "guix build ..." breaks if I try to include "(gnu packages
> cargo-xyz)" (or "(guix packages cargo-xyz)").
>
> My mistake, it's actually ``crates-xyz'' :P
>

Oh no, it's all good... But I don't see "crates-xyz" (or just xyz) in
guix's packages.

   - https://packages.guix.gnu.org/search/?query=crates-xyz
   - https://packages.guix.gnu.org/search/?query=xyz


$ guix build -L ~/dotfiles/ rustscan
guix build: warning: failed to load '(guix packages rustscan)':
no code for module (gnu packages crates-xyz)


What is "crates-xyz" meant to do? And where is its definition?

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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-25 20:44         ` Timothy Washington
@ 2023-04-26  5:43           ` (
  2023-04-27  4:53             ` Timothy Washington
  0 siblings, 1 reply; 12+ messages in thread
From: ( @ 2023-04-26  5:43 UTC (permalink / raw)
  To: Timothy Washington; +Cc: help-guix

Timothy Washington <twashing@gmail.com> writes:
> What is "crates-xyz" meant to do? And where is its definition?

Okay, apparently it's actually ``crates-io'' :P (this time i actually
checked...)


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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-26  5:43           ` (
@ 2023-04-27  4:53             ` Timothy Washington
  2023-04-27 16:36               ` (
  0 siblings, 1 reply; 12+ messages in thread
From: Timothy Washington @ 2023-04-27  4:53 UTC (permalink / raw)
  To: (; +Cc: help-guix

Thanks very much for your help. I got past that bit. Below is the config
that got me through it.

(define-module (guix packages rustscan)
  ...
  #:use-module (gnu packages crates-io))


(define-public rustscan
  (package
   ...
   (arguments
    `(#:cargo-inputs
      (("rust-ansi-term" ,rust-ansi-term-0.12))))
   (home-page "https://github.com/RustScan/RustScan")
   ...
   ))


The build is still looking for a different package now (anyhow). But I can
find that once https://packages.guix.gnu.org/ comes back online, from its
outage, lol.

starting phase `build'
error: no matching package named `anyhow` found
location searched: registry `crates-io`
required by package `rustscan v2.1.1
(/tmp/guix-build-rustscan-2.1.1.drv-0/source)`



Thanks again!
Tim



On Wed, 26 Apr 2023 at 01:43, ( <paren@disroot.org> wrote:

> Timothy Washington <twashing@gmail.com> writes:
> > What is "crates-xyz" meant to do? And where is its definition?
>
> Okay, apparently it's actually ``crates-io'' :P (this time i actually
> checked...)
>

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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-27  4:53             ` Timothy Washington
@ 2023-04-27 16:36               ` (
  2023-04-28  3:06                 ` Timothy Washington
  0 siblings, 1 reply; 12+ messages in thread
From: ( @ 2023-04-27 16:36 UTC (permalink / raw)
  To: Timothy Washington; +Cc: help-guix

Timothy Washington <twashing@gmail.com> writes:
>  starting phase `build'
>  error: no matching package named `anyhow` found
>  location searched: registry `crates-io`
>  required by package `rustscan v2.1.1 (/tmp/guix-build-rustscan-2.1.1.drv-0/source)`

Just add the input to the #:CARGO-INPUTS:

```
`(...
  (("rust-anyhow" ,rust-anyhow-2)))
```

Make sure to keep the inputs in alphabetical order :)


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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-27 16:36               ` (
@ 2023-04-28  3:06                 ` Timothy Washington
  2023-04-28 14:23                   ` (
  0 siblings, 1 reply; 12+ messages in thread
From: Timothy Washington @ 2023-04-28  3:06 UTC (permalink / raw)
  To: (; +Cc: help-guix

Ok nice. I got much further with the rust-anyhow definition here
<https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/crates-io.scm#n2773>
(in crates-io).

With these arguments..

   (arguments
    `(#:cargo-inputs
      (("rust-ansi-term" ,rust-ansi-term-0.12)
       ("rust-anyhow" ,rust-anyhow-1))))


..the build fails on missing "cidr-utils". Now "cidr-utils" is in Rust's
crates.io <https://crates.io/crates/cidr-utils>.
But is that what Guix' cargo-build-system is referencing?
Otherwise, do we need to create a Guix .scm (scheme definition)?

starting phase `build'
error: no matching package found
searched package name: `cidr-utils`
perhaps you meant:      pin-utils
location searched: registry `crates-io`
required by package `rustscan v2.1.1
(/tmp/guix-build-rustscan-2.1.1.drv-0/source)`
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "cargo" arguments: ("build"
"--release") exit-status: 101 term-signal: #f stop-signal: #f>



Tim


On Thu, 27 Apr 2023 at 12:37, ( <paren@disroot.org> wrote:

> Timothy Washington <twashing@gmail.com> writes:
> >  starting phase `build'
> >  error: no matching package named `anyhow` found
> >  location searched: registry `crates-io`
> >  required by package `rustscan v2.1.1
> (/tmp/guix-build-rustscan-2.1.1.drv-0/source)`
>
> Just add the input to the #:CARGO-INPUTS:
>
> ```
> `(...
>   (("rust-anyhow" ,rust-anyhow-2)))
> ```
>
> Make sure to keep the inputs in alphabetical order :)
>

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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-28  3:06                 ` Timothy Washington
@ 2023-04-28 14:23                   ` (
  2023-04-28 20:08                     ` Timothy Washington
  0 siblings, 1 reply; 12+ messages in thread
From: ( @ 2023-04-28 14:23 UTC (permalink / raw)
  To: Timothy Washington; +Cc: help-guix

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.


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

* Re: Howto supply cargo-build-system dependency to guix package definition
  2023-04-28 14:23                   ` (
@ 2023-04-28 20:08                     ` Timothy Washington
  0 siblings, 0 replies; 12+ messages in thread
From: Timothy Washington @ 2023-04-28 20:08 UTC (permalink / raw)
  To: (; +Cc: help-guix

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

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

end of thread, other threads:[~2023-05-01 16:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-23 16:18 Howto supply cargo-build-system dependency to guix package definition Timothy Washington
2023-04-24  6:19 ` (
2023-04-24  6:23   ` (
2023-04-25  3:48     ` Timothy Washington
2023-04-25  5:56       ` (
2023-04-25 20:44         ` Timothy Washington
2023-04-26  5:43           ` (
2023-04-27  4:53             ` Timothy Washington
2023-04-27 16:36               ` (
2023-04-28  3:06                 ` Timothy Washington
2023-04-28 14:23                   ` (
2023-04-28 20:08                     ` Timothy Washington

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.