all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Current state of cargo-build-system
@ 2019-01-21  0:11 Ivan Petkov
  2019-01-23 10:50 ` Ludovic Courtès
  2019-01-23 17:10 ` Danny Milosavljevic
  0 siblings, 2 replies; 8+ messages in thread
From: Ivan Petkov @ 2019-01-21  0:11 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

Hello Guix!

I'm new to both Guix and Guile/Scheme and decided to get my feet wet by
attempting to package a non-trivial Rust crate into Guix.

This seems like something others have tried before me with varying degrees of
success (I found this thread from a few years ago which doesn't seem to have
resolved in any way https://lists.gnu.org/archive/html/guix-devel/2017-01/msg00306.html <https://lists.gnu.org/archive/html/guix-devel/2017-01/msg00306.html>).
I ran into a host of issues myself, but I was able to prototype some changes
which allowed me to make some progress. Happy to keep hacking on this, but
ultimately I need some insight/guidance on the proper ways to build this out in
Guix :)

But before I propose any new changes, I wanted to check, what is the current
state cargo/crates in Guix from a community perspective?

Are there any philosophical or technical blockers that preclude pulling in
packages from crates.io, or is it just a matter of chipping away at the problem?

--Ivan

[-- Attachment #2: Type: text/html, Size: 1711 bytes --]

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

* Re: Current state of cargo-build-system
  2019-01-21  0:11 Current state of cargo-build-system Ivan Petkov
@ 2019-01-23 10:50 ` Ludovic Courtès
  2019-01-23 11:46   ` ng0
  2019-01-23 17:10 ` Danny Milosavljevic
  1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2019-01-23 10:50 UTC (permalink / raw)
  To: Ivan Petkov; +Cc: guix-devel

Hello Ivan,

Ivan Petkov <ivanppetkov@gmail.com> skribis:

> I'm new to both Guix and Guile/Scheme and decided to get my feet wet by
> attempting to package a non-trivial Rust crate into Guix.

Cool, thanks for getting in touch!

> This seems like something others have tried before me with varying degrees of
> success (I found this thread from a few years ago which doesn't seem to have
> resolved in any way https://lists.gnu.org/archive/html/guix-devel/2017-01/msg00306.html <https://lists.gnu.org/archive/html/guix-devel/2017-01/msg00306.html>).
> I ran into a host of issues myself, but I was able to prototype some changes
> which allowed me to make some progress. Happy to keep hacking on this, but
> ultimately I need some insight/guidance on the proper ways to build this out in
> Guix :)

I think Danny and maybe ng0 (Cc’d) may be those the most familiar with
Rust in Guix.

> But before I propose any new changes, I wanted to check, what is the current
> state cargo/crates in Guix from a community perspective?
>
> Are there any philosophical or technical blockers that preclude pulling in
> packages from crates.io, or is it just a matter of chipping away at the problem?

I don’t think there are any “philosophical” blockers: as long as this is
free software, which I believe is the case for most packages on
crates.io, there shouldn’t be any problems.

As for the technical issues, I don’t know.  I remember David Craven, who
wrote ‘guix import crate’, didn’t do a mass import back then, but then
the ‘rust’ package in Guix was also nascent at the time so perhaps there
were other problems that have been resolved since then.

Anyway, I think you can go ahead and start experimenting, adding new
packages, etc.  Let us know how it goes, and do ping Danny and ng0 as
needed!  :-)

Thanks,
Ludo’.

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

* Re: Current state of cargo-build-system
  2019-01-23 10:50 ` Ludovic Courtès
@ 2019-01-23 11:46   ` ng0
  0 siblings, 0 replies; 8+ messages in thread
From: ng0 @ 2019-01-23 11:46 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courts transcribed 1.9K bytes:
> Hello Ivan,
> 
> Ivan Petkov <ivanppetkov@gmail.com> skribis:
> 
> > I'm new to both Guix and Guile/Scheme and decided to get my feet wet by
> > attempting to package a non-trivial Rust crate into Guix.
> 
> Cool, thanks for getting in touch!
> 
> > This seems like something others have tried before me with varying degrees of
> > success (I found this thread from a few years ago which doesn't seem to have
> > resolved in any way https://lists.gnu.org/archive/html/guix-devel/2017-01/msg00306.html <https://lists.gnu.org/archive/html/guix-devel/2017-01/msg00306.html>).
> > I ran into a host of issues myself, but I was able to prototype some changes
> > which allowed me to make some progress. Happy to keep hacking on this, but
> > ultimately I need some insight/guidance on the proper ways to build this out in
> > Guix :)
> 
> I think Danny and maybe ng0 (Cc’d) may be those the most familiar with
> Rust in Guix.

Not really. I know there were some tickets and bugs/features left to be worked on,
but that's about it. Other people took over work, and I'm mostly involved in
other projects now (pkgsrc, GNUnet, TALER admin, university, my package manager
work, etc).
But I can try to answer questions.
 
> > But before I propose any new changes, I wanted to check, what is the current
> > state cargo/crates in Guix from a community perspective?
> >
> > Are there any philosophical or technical blockers that preclude pulling in
> > packages from crates.io, or is it just a matter of chipping away at the problem?
> 
> I don’t think there are any “philosophical” blockers: as long as this is
> free software, which I believe is the case for most packages on
> crates.io, there shouldn’t be any problems.
> 
> As for the technical issues, I don’t know.  I remember David Craven, who
> wrote ‘guix import crate’, didn’t do a mass import back then, but then
> the ‘rust’ package in Guix was also nascent at the time so perhaps there
> were other problems that have been resolved since then.

Yeah, I haven't tried re-importing my rust packages tree. Maybe it's better now for a fraction
of those.
 
> Anyway, I think you can go ahead and start experimenting, adding new
> packages, etc.  Let us know how it goes, and do ping Danny and ng0 as
> needed!  :-)
> 
> Thanks,
> Ludo’.
> 

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

* Re: Current state of cargo-build-system
  2019-01-21  0:11 Current state of cargo-build-system Ivan Petkov
  2019-01-23 10:50 ` Ludovic Courtès
@ 2019-01-23 17:10 ` Danny Milosavljevic
  2019-01-25 23:57   ` Ivan Petkov
  1 sibling, 1 reply; 8+ messages in thread
From: Danny Milosavljevic @ 2019-01-23 17:10 UTC (permalink / raw)
  To: Ivan Petkov; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 1560 bytes --]

Hi Ivan,

On Sun, 20 Jan 2019 16:11:58 -0800
Ivan Petkov <ivanppetkov@gmail.com> wrote:

> Are there any philosophical or technical blockers that preclude pulling in
> packages from crates.io, 

Cycles.  Also, often Cargo.lock specifies exact versions of dependencies (in
programs, at least).

>or is it just a matter of chipping away at the problem?

Pretty much.

Back in the day, Rust was in a state of flux.  Now, I think they finally
committed to not changing the floor from under us while we are walking on it
(the "edition" key in Cargo.toml is used to select the Rust version to target).
So it makes sense to try again now.

First, we'd have to find out what kind of things Cargo can build and how to
detect it.

I've used Rust to write a tiny operating system - and there, I use a hybrid
configuration for the same package: it's both a library and a program.
For that, I used a directory with files src/lib.rs and src/main.rs in it, but
I'm not sure whether that's set in stone or just what I came up with / the
tutorial says.

See also <https://github.com/rust-lang-nursery/api-guidelines/issues/167>.

After that, we can decide whether to compile libraries or just ship them as
source (right now, we do the latter pretty often - almost everything in Guix
Rust library packages ends up in the "src" output).

Getting the unit tests to run often requires breaking many cycles, so maybe
skip that at first.

I've attached my ancient attempt to package some crates--but I think ng0's
patchset is nicer than that.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: crates.scm --]
[-- Type: text/x-scheme, Size: 39093 bytes --]

(define-module (wip crates)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix build-system cargo)
  #:use-module (guix gexp)
  #:use-module (gnu packages)
  #:use-module (gnu packages linux) ; strace
  #:use-module (gnu packages rust)
  #:use-module (gnu packages pkg-config))

;;; FIXME websocket crate, tokio, slack-rs.

(define-public rust-rand-bootstrap
  (package
    (name "rust-rand-bootstrap")
    (version "0.3.15")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/daym/nonrand/archive/v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0m59msxrxwgwn7sissm6df1ly9zgyy1i53r6n98ajp3ch51myx21"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    ;(propagated-inputs
    ; `(("rust-libc" ,rust-libc)))
    ;(native-inputs
    ; `(("rust-log" ,rust-log)))
    (home-page "https://github.com/rust-lang/rand")
    (synopsis "Random number generators")
    (description "Random number generator that yields non-random numbers.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-tempdir-bootstrap
 (package
  (name "rust-tempdir-bootstrap")
  (version "0.3.5")
  (source
    (origin
      (method url-fetch)
      (uri (crate-uri "tempdir" version))
      (file-name
        (string-append name "-" version ".tar.gz"))
      (sha256
        (base32
          "1mij45kgzflkja0h8q9avrik76h5a0b60m9hfd6k9yqxbiplm5w7"))
      (modules '((guix build utils)))
      (snippet
       '(substitute* "Cargo.toml"
          (("^rand") "nonrand")))))
  (build-system cargo-build-system)
  (propagated-inputs `(("rust-rand" ,rust-rand-bootstrap)))
  (home-page
    "https://github.com/rust-lang/tempdir")
  (synopsis
    "Library for managing a temporary directory in Rust")
    (description "This package provides a library for managing a temporary directory
and deleting all contents when it's dropped.
")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-gcc-bootstrap
  (package
    (name "rust-gcc-bootstrap")
    (version "0.3.40")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "gcc" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0l6rnf3b7vaxhcs7yg9nyv7brqidy2g0xhg8z0a2pvw6jkjvjbc7"))
        (modules '((guix build utils)))
        (snippet
         '(substitute* "Cargo.toml"
            (("^rayon.*") "
")
            (("^tempdir.*") "
")
            (("\"rayon\"") ""))))) ; TODO be nicer about it
    (build-system cargo-build-system)
    ;(arguments
    ; `(#:cargo-build-flags '("--features" "")))
    (native-inputs
     `(("rust-tempdir" ,rust-tempdir-bootstrap "src")))
    ; (inputs `(("rust-rayon" ,rust-rayon "src"))) ; optional
    (home-page "FIXME")
    (synopsis "Invoke the native C compiler to compile native C code into a static archive")
    (description "This package provides a build-time dependency for Cargo build scripts to
assist in invoking the native C compiler to compile native C code into a static
archive to be linked into Rust code.
")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-bitflags
  (package
    (name "rust-bitflags")
    (version "0.7.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "bitflags" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0v8hh6wdkpk9my8z8442g4hqrqf05h0qj53dsay6mv18lqvqklda"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (home-page "https://github.com/rust-lang/bitflags")
    (synopsis "Macro to generate structures which behave like bitflags,
in Rust")
    (description "@code{bitflags} provides a macro to generate structures
which behave
like bitflags, in Rust.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

;;; TODO syntex-errors remove libc dependency again (isatty).

(define-public rust-syntex-syntax-bootstrap ; FIXME test whether it works with a very old syntex-syntax
  (package
    (name "rust-syntex-syntax-bootstrap")
    (version "0.3.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "syntex_syntax" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "05rahy6vlr82nvf8fx1y8a6qzbspymhh1ja06lwi3b0kv26jrshn"))
        (modules '((guix build utils)))
        (snippet
         '(begin
           (substitute* "src/lib.rs"
            (("^#![[]feature.*") "
")
            (("^extern crate libc;") "
"))
           (substitute* "Cargo.toml"
            (("^libc.*") "
"))
           (substitute* "src/parse/mod.rs"
            ;; Only used on Windows
            (("libc::consts::os::extra::O_BINARY") "0"))))))
    (build-system cargo-build-system)
    (propagated-inputs
     `(("rust-bitflags" ,rust-bitflags "src")))
    (home-page "FIXME")
    (synopsis "Export of libsyntax for code generation")
    (description "Export of libsyntax for code generation")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-ctest-bootstrap
  (package
    (name "rust-ctest-bootstrap")
    (version "0.1.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "ctest" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0wlsw2ab36jqdcdzwxd58pir782449b937kljhxl49y7jzf2ssqm"))))
    (build-system cargo-build-system)
    (propagated-inputs
     `(("rust-gcc-bootstrap" ,rust-gcc-bootstrap "src") ; sometimes cycle because of rust-gcc - rust-tempdir - rust-rand - rust-libc; note: also because of rust-rayon as well.
       ("rust-syntex-syntax-bootstrap" ,rust-syntex-syntax-bootstrap "src")))
    (home-page "https://github.com/alexcrichton/ctest")
    (synopsis "Automated tests of FFI bindings.")
    (description "Automated tests of FFI bindings.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-libc
  (package
    (name "rust-libc")
    (version "0.2.18")
    (source
     (origin
       (method url-fetch)
       ;; (crate-uri "libc" version) doesn't contain libc-test.
       (uri (string-append "https://github.com/rust-lang/libc/archive/" version ".tar.gz"))
       (file-name (string-append name "-" version ".tar.gz"))
       (sha256
        (base32
         "1mh62gfm91aypbr830m2qklwgscgb0pcfpxzi3a6k60faamlrndf"))))
    (build-system cargo-build-system)
    ;(native-inputs
    ; `(("rust-ctest-bootstrap" ,rust-ctest-bootstrap "src")))
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'delete-lock
           (lambda _
             (delete-file "Cargo.lock")
             #t))
         (delete 'build))))
    (home-page "https://github.com/rust-lang/libc")
    (synopsis "Raw bindings to platform APIs for Rust")
    (description
     "Libc provides a library for types and bindings to native
C functions often found in libc or other common platform libraries.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-c-vec
  (package
    (name "rust-c-vec")
    (version "1.2.0")
    (source
      (origin
        ;(method git-fetch)
        ;(uri (git-reference
        ;       (url "https://github.com/GuillaumeGomez/c_vec-rs.git")
        ;       (commit "ee4ccb4ecb092926175ec58c60434ee153190aa8")))
        (method url-fetch)
        (uri (crate-uri "c_vec" version))
        (file-name
          (string-append name "-" version "-checkout"))
        (sha256
          (base32
            "01y5rllqclky30mskrycfm5i9nng5k2xsyksjg9lnapnb2kgan80"))))
    (build-system cargo-build-system)
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (add-after 'build 'delete-lock
           (lambda _
             (delete-file "Cargo.lock")
             #t)))))
    (native-inputs `(("rust-libc" ,rust-libc "src")))
    (home-page "https://github.com/GuillaumeGomez/c_vec-rs") ; FIXME fixed manually. It said ()
    (synopsis "Structures to wrap C arrays")
    (description "Structures to wrap C arrays")
    ;; Choose either license.
    (license (list license:asl2.0 license:expat))))

;; Requires inline assembly and so doesn't work on Rust stable.
(define-public rust-spin
  (package
    (name "rust-spin")
    (version "0.4.5")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "spin" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0lvyyxg646wl67b41655p2z25s725sw1rsfvpnm8d7vq5dpa45hx"))))
    (build-system cargo-build-system)
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         ;; Spin doesn't actually work - so don't build it.
         (delete 'build))))
    (home-page "https://github.com/mvdnes/spin-rs.git")
    (synopsis "Synchronization primitives based on spinning, for Rust")
    (description
    "@code{spin} provides synchronization primitives based on spinning.
They don't work in Rust stable, however. This is a dummy package to make
Cargo find (and hopefully not use) it.")
    (license license:expat)))

(define-public rust-lazy-static
  (package
    (name "rust-lazy-static")
    (version "0.2.4")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "lazy_static" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1p30qiivkkg1d43s10pj3g07zpriqbdxy0hbc99gfcfkjzfv34bj"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch
           (lambda _
;             (substitute* "Cargo.toml"
;               (("^[[]dependencies[.]spin[]]") "")
;               (("^version = \"0.4\"") "") ; spin
;               (("^optional = true") "") ; spin
;               (("^spin_no_std.*") "
;"))
             #t))
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (inputs
     `(;; Even though rust-spin doesn't work on Rust stable,
       ;; Cargo requires it to be there.
       ("rust-spin" ,rust-spin "src")))
    (home-page "https://github.com/rust-lang-nursery/lazy-static.rs")
    (synopsis "Macro for declaring lazily evaluated statics in Rust")
    (description "@code{lazy_static} provides a macro for declaring lazily
evaluated statics in Rust.")
    (license license:expat)))

(define-public rust-pkg-config
  (package
    (name "rust-pkg-config")
    (version "0.3.9")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "pkg-config" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "00x9vc7667m4r8sn8idgpmj9yf1ih6bj1cdrshf1mkb5h5mlr2rs"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (native-inputs
     `(("rust-lazy-static" ,rust-lazy-static "src")))
    (home-page "https://github.com/alexcrichton/pkg-config-rs")
    (synopsis "Library to run the @code{pkg-config} system tool at build
time in Rust")
    (description "@code{pkg-config} provides a library that invokes the
@code{pkg-config} system tool at build time in Rust (to be used in Cargo
build scripts).")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-log
  (package
    (name "rust-log")
    (version "0.3.6")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "log" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0m40hgs3cg57dd5kk1mabfk6gk8z6l1cihar8akx4kmzz1xlk0xb"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (home-page "https://github.com/rust-lang/log")
    (synopsis "Logging interface for Rust")
    (description "@code{log} provides a logging facade for Rust.  Libraries
can use the provided logging API, and the consumer of those libraries can
choose the logging implementation that is most suitable for its use case.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

;; Contains broken members
(define-public rust-futures
  (package
    (name "rust-futures")
    (version "0.1.10")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "futures" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0hdwwbwld2af0g53rlgawxgz7sjmv9zinqzrrfxv2h1q12vkx4f1"))))
    (build-system cargo-build-system)
    (inputs `(("rust-log" ,rust-log "src")))
    (home-page
      "https://github.com/alexcrichton/futures-rs")
    (synopsis
      "An implementation of futures and streams featuring zero allocations,
composability, and iterator-like interfaces.
")
    (description
    "An implementation of futures and streams featuring zero allocations,
composability, and iterator-like interfaces.
")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-rand
  (package
    (name "rust-rand")
    (version "0.3.15")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rand" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "178qgglinqawwsw6l8imgnplxkmxcj404jqm92pds695xhv0cbh2"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (native-inputs
     `(("rust-log" ,rust-log "src")))
    (propagated-inputs
     `(("rust-libc" ,rust-libc "src")))
    (home-page "https://github.com/rust-lang/rand")
    (synopsis "Random number generators for Rust")
    (description "@code{rand} provides random number generators and other randomness functionality for Rust.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

;; Error: unused imports (WTF). Dependency: rust-byteorder, which requires quickcheck, which is broken.
(define-public rust-bytes
  (package
    (name "rust-bytes")
    (version "0.4.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "bytes" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "12m10gdkvlwrn7d5p1j102sf3fy3gq5rs3izwvvbsz4kpf2knl46"))))
    (build-system cargo-build-system)
    (propagated-inputs
     `(("rust-rand" ,rust-rand "src")
       ("rust-byteorder" ,rust-byteorder "src")))
    (home-page "https://github.com/carllerche/bytes")
    (synopsis
      "Types and traits for working with bytes")
    (description
      "Types and traits for working with bytes.")
    (license license:expat)))

;; Reference cycle
(define-public rust-quickcheck
  (package
    (name "rust-quickcheck")
    (version "0.4.2")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "quickcheck" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "16symxywrj4qh431wjhl7zvzv4n9hp111dmn9qnj1kqq830r9wiy"))))
    (build-system cargo-build-system)
    (inputs
     `( ; FIXME fix loop ("rust-env-logger" ,rust-env-logger "src")
       ("rust-log" ,rust-log "src")
       ("rust-rand" ,rust-rand "src")))
    (home-page
      "https://github.com/BurntSushi/quickcheck")
    (synopsis
      "Automatic property based testing with shrinking.")
    (description
      "Automatic property based testing with shrinking.")
    (license (list license:unlicense license:expat))))

(define-public rust-regex-syntax
  (package
    (name "rust-regex-syntax")
    (version "0.4.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "regex-syntax" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0ms4s2zdr9lr79isjphqqg2wkc8rblvpwcax21ghj0vnynqr349g"))))
    (build-system cargo-build-system)
    (native-inputs
     `(("rust-quickcheck" ,rust-quickcheck "src")
       ("rust-rand" ,rust-rand "src")))
    (home-page "https://github.com/rust-lang/regex")
    (synopsis "A regular expression parser.")
    (description
      "This package provides a regular expression parser.")
    (license (list license:expat license:asl2.0))))

;; Broken because quickcheck is broken.
(define-public rust-utf8-ranges
  (package
    (name "rust-utf8-ranges")
    (version "1.0.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "utf8-ranges" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "08j129anwcbdwvcx1izb4nsf0nbxksin2zqxjbrfz2x94mjsnbv6"))))
    (build-system cargo-build-system)
    (native-inputs
     `(("rust-quickcheck" ,rust-quickcheck "src")))
    (home-page
      "https://github.com/BurntSushi/utf8-ranges")
    (synopsis
      "Convert ranges of Unicode codepoints to UTF-8 byte ranges.")
    (description
      "Convert ranges of Unicode codepoints to UTF-8 byte ranges.")
    (license (list license:unlicense license:expat))))

;; Broken because quickcheck is broken
(define-public rust-memchr
  (package
    (name "rust-memchr")
    (version "1.0.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "memchr" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1d27b8kk2zijj6f9qlcwa4q71lkbm72nfvbyy6wlgspi8q7crg0x"))))
    (build-system cargo-build-system)
    (native-inputs
     `(("rust-quickcheck" ,rust-quickcheck "src")))
    (inputs `(("rust-libc" ,rust-libc "src")))
    (home-page "https://github.com/BurntSushi/rust-memchr")
    (synopsis "Safe interface to memchr.")
    (description "Safe interface to memchr.")
    (license (list license:unlicense license:expat))))

;; Fails because of quickcheck
(define-public rust-byteorder
  (package
    (name "rust-byteorder")
    (version "1.0.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "byteorder" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1j0qvrvpmk01v5qkmp5l7gmjvlpxxygivm1w074qb63bxsq7f2f4"))))
    (build-system cargo-build-system)
    (native-inputs
      `(("rust-quickcheck" ,rust-quickcheck "src")
        ("rust-rand" ,rust-rand "src")))
    (home-page
      "https://github.com/BurntSushi/byteorder")
    (synopsis
      "Library for reading/writing numbers in big-endian and little-endian.")
    (description
      "Library for reading/writing numbers in big-endian and little-endian.")
    (license (list license:unlicense license:expat))))

;; Reference cycle
(define-public rust-csv
  (package
    (name "rust-csv")
    (version "0.15.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "csv" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "173dv65zmmm4kfqnjk66vhgj4w82vh9c14jq6r55c755qwvjpwky"))))
    (build-system cargo-build-system)
    (native-inputs
      `(("rust-regex" ,rust-regex "src")))
    (inputs
      `(("rust-byteorder" ,rust-byteorder "src")
        ("rust-memchr" ,rust-memchr "src")
        ; FIXME ("rust-rustc-serialize" ,rust-rustc-serialize "src")
))
    (home-page
      "https://github.com/BurntSushi/rust-csv")
    (synopsis
      "CSV parsing with automatic type based decoding and encoding.")
    (description
      "CSV parsing with automatic type based decoding and encoding.")
    (license (list license:unlicense license:expat))))

(define-public rust-strsim
  (package
    (name "rust-strsim")
    (version "0.6.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "strsim" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "151ngha649cyybr3j50qg331b206zrinxqz7fzw1ra8r0n0mrldl"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (home-page "https://github.com/dguo/strsim-rs")
    (synopsis
      "String similarity metrics")
    (description
      "@code{strsim} contains implementations of string similarity metrics.
Includes Hamming, Levenshtein, Damerau-Levenshtein, Jaro, and Jaro-Winkler.")
    (license license:expat)))

;; Reference cycle
(define-public rust-docopt
  (package
    (name "rust-docopt")
    (version "0.7.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "docopt" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1n6gbhsks2w9y0b4bwqyawh4ghbkka09w6pjcrq9i1sd51pflcmb"))))
    (build-system cargo-build-system)
    (inputs
     `(("rust-lazy-static" ,rust-lazy-static "src")
       ("rust-regex" ,rust-regex "src")
       ; FIXME ("rust-rustc-serialize" ,rust-rustc-serialize "src")
       ("rust-strsim" ,rust-strsim "src")))
    (home-page "https://github.com/docopt/docopt.rs")
    (synopsis "Command line argument parsing.")
    (description "Command line argument parsing.")
    (license (list license:unlicense license:expat))))

;; #![cfg_attr(test, feature(test))] is unstable. So it breaks.
(define-public rust-fs2
  (package
    (name "rust-fs2")
    (version "0.4.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "fs2" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1bsb3x8mkffsnr4xd5ac6v8b8sv80npfd1x37k0rv1amfphaxv9l"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch
           (lambda _
             (substitute* "src/lib.rs"
               (("#[!][[]cfg_attr[(]test, feature[(]test[)][)][]]") ""))
             #t)))))
    (native-inputs
     `(("rust-tempdir" ,rust-tempdir "src")))
    (inputs
     `(("rust-libc" ,rust-libc "src")))
    (home-page "https://github.com/danburkert/fs2-rs")
    (synopsis "Cross-platform file locks and file duplication.")
    (description "Cross-platform file locks and file duplication.")
    (license (list license:expat license:asl2.0))))

(define-public rust-memmap
  (package
    (name "rust-memmap")
    (version "0.5.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "memmap" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1lmbkx92xlqb5yqh4cj2k4qfrm3x4jkbs04i84nfl60wyfdfap06"))))
    (build-system cargo-build-system)
    (native-inputs
     `(("rust-tempdir" ,rust-tempdir "src")))
    (inputs
     `(("rust-fs2" ,rust-fs2 "src")
       ("rust-libc" ,rust-libc "src")))
    (home-page
      "https://github.com/danburkert/memmap-rs")
    (synopsis
      "Cross-platform Rust API for memory-mapped file IO in Rust")
    (description
      "@code{memmap} provides a cross-platform Rust API for memory-mapped
file IO in Rust.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

;; Reference cycle
(define-public rust-aho-corasick
  (package
    (name "rust-aho-corasick")
    (version "0.6.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "aho-corasick" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1gymiyg646qyfzb0abqhmpxpd5smpcv4nyzhr5b9p5v24ya0nrjg"))))
    (build-system cargo-build-system)
    (native-inputs
      `(("rust-csv" ,rust-csv "src")
        ("rust-docopt" ,rust-docopt "src")
        ("rust-memmap" ,rust-memmap "src")
        ("rust-quickcheck" ,rust-quickcheck "src")
        ("rust-rand" ,rust-rand "src")
;        ("rust-rustc-serialize" ,rust-rustc-serialize "src")
))
    (inputs `(("rust-memchr" ,rust-memchr "src")))
    (home-page "https://github.com/BurntSushi/aho-corasick")
    (synopsis "Fast multiple substring searching with finite state machines.")
    (description "Fast multiple substring searching with finite state machines.")
    (license (list license:unlicense license:expat))))

;(define-public rust-simd
;  (package
;    (name "rust-simd")
;    (version "0.2.0")
;    (source
;      (origin
;        (method url-fetch)
;        (uri (crate-uri "simd" version))
;        (file-name
;          (string-append name "-" version ".tar.gz"))
;        (sha256
;          (base32
;            "183vwg7c5z4pl0wifzhw31h2adwlwilzprbxjc8g3wg1595d353s"))))
;    (build-system cargo-build-system)
;    (native-inputs
;     `(("rust-cfg-if" ,rust-cfg-if "src")))
;    (inputs
;     `(("rust-serde" ,rust-serde "src")
;       ("rust-serde-derive" ,rust-serde-derive "src")))
;    (home-page "https://github.com/rust-lang-nursery/simd")
;    (synopsis "SIMD instructions")
;    (description "@code{simd} offers limited cross-platform access to SIMD
;instructions on CPUs, as well as raw interfaces to platform-specific
;instructions.")
;  (license (list license:expat license:asl2.0))))

;; Dependency cycle
(define-public rust-regex
  (package
    (name "rust-regex")
    (version "0.2.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "regex" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "008cl7l1pssf8xihgy23508d5msvnkz2h05h1bpxyqkd1xyw2y22"))))
    (build-system cargo-build-system)
    (native-inputs
      `(("rust-lazy-static" ,rust-lazy-static "src")
        ("rust-quickcheck" ,rust-quickcheck "src")
        ("rust-rand" ,rust-rand "src")))
    (inputs
      `(("rust-aho-corasick" ,rust-aho-corasick "src")
        ("rust-memchr" ,rust-memchr "src")
        ("rust-regex-syntax" ,rust-regex-syntax "src")
        ;("rust-simd" ,rust-simd "src")
        ; FIXME ("rust-thread-local" ,rust-thread-local "src")
        ("rust-utf8-ranges" ,rust-utf8-ranges "src")))
    (home-page "https://github.com/rust-lang/regex")
    (synopsis
    "An implementation of regular expressions for Rust. This implementation uses
finite automata and guarantees linear time matching on all inputs.
")
    (description
    "An implementation of regular expressions for Rust.  This implementation uses
finite automata and guarantees linear time matching on all inputs.
")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

;; Dependency cycle
(define-public rust-env-logger
  (package
    (name "rust-env-logger")
    (version "0.4.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "env_logger" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0i21vvjyr49kc6si6mivla0clg5rbf26bl64wc77mzimnsqiz5wr"))))
    (build-system cargo-build-system)
    (inputs
      `(("rust-log" ,rust-log "src")
        ("rust-regex" ,rust-regex "src")))
    (home-page "https://github.com/rust-lang/log")
    (synopsis
    "A logging implementation for `log` which is configured via an environment
variable.
")
    (description
    "This package provides a logging implementation for `log` which is configured via an environment
variable.
")
    (license (list license:expat license:asl2.0))))

;; Required dependency clippy is missing
(define-public rust-lazycell
  (package
    (name "rust-lazycell")
    (version "0.5.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "lazycell" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0cb3h771aqnq753krx6f6vpxw3nn41b8gaj24q6y7wqy5z1aaf7c"))))
    (build-system cargo-build-system)
    ; FIXME why? (inputs `(("rust-clippy" ,rust-clippy "src")))
    (home-page "https://github.com/indiv0/lazycell")
    (synopsis "Library providing a lazily filled Cell struct in Rust")
    (description "@code{lazycell} provides a library for lazily filled Cell
structs in Rust.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-cfg-if
  (package
    (name "rust-cfg-if")
    (version "0.1.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "cfg-if" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "137qikjcal4h75frzcn6mknygqk8vy5bva7w851aydb5gc6pc7ny"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (home-page "https://github.com/alexcrichton/cfg-if")
    (synopsis "Ergonomically define an item depending on a large number of
@code{#[cfg]} parameters in Rust")
    (description
    "@code{cfg-if} provides a macro to ergonomically define an item depending
on a large number of #[cfg] parameters in Rust.  Structured like an if-else
chain, the first matching branch is the item that gets emitted.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

(define-public rust-net2
  (package
    (name "rust-net2")
    (version "0.2.26")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "net2" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1qp3q6xynb481rsp3ig1nmqb6qlxfba3shfrmqij88cppsv9rpsy"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (inputs
     `(("rust-cfg-if" ,rust-cfg-if "src")
       ;("rust-kernel32-sys" ,rust-kernel32-sys "src")
        ("rust-libc" ,rust-libc "src")
       ;("rust-winapi" ,rust-winapi "src")
       ;("rust-ws2-32-sys" ,rust-ws2-32-sys "src")
))
  (home-page
    "https://github.com/rust-lang-nursery/net2-rs")
  (synopsis
    "Extensions to the standard library's networking types as proposed in RFC 1158.
")
  (description
    "Extensions to the standard library's networking types as proposed in RFC 1158.
")
  (license (list license:expat license:asl2.0))))

(define-public rust-slab
  (package
    (name "rust-slab")
    (version "0.3.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "slab" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "08xw8w61zdfn1094qkq1d554vh5wmm9bqdys8gqqxc4sv2pgrd0p"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (home-page "https://github.com/carllerche/slab")
    (synopsis "Simple slab allocator")
    (description "@code{slab} provides a SLAB allocator for Rust.  It
preallocates memory for values of a given type.")
    (license license:expat)))

(define-public rust-epoll
  (package
    (name "rust-epoll")
    (version "2.1.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "epoll" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1al3bcaqwgdq9kfk9xhkdg4nhjbhjz64r51y4v89qc02bbgz8f7l"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (inputs
     `(("rust-bitflags" ,rust-bitflags "src")
       ("rust-libc" ,rust-libc "src")))
    (home-page
      "https://github.com/nathansizemore/epoll")
    (synopsis "Safe epoll interface.")
    (description "Safe epoll interface.")
    (license license:mpl2.0)))

(define-public rust-tempdir
  (package
    (name "rust-tempdir")
    (version "0.3.5")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "tempdir" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1mij45kgzflkja0h8q9avrik76h5a0b60m9hfd6k9yqxbiplm5w7"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (propagated-inputs
     `(("rust-rand" ,rust-rand "src")))
    (home-page "https://github.com/rust-lang/tempdir")
    (synopsis "Manages a temporary directory in Rust")
    (description"@code{tempdir} provides a library for managing a temporary
directory and deleting all contents when it's dropped, in Rust.")
    ;; Choose either license.
    (license (list license:expat license:asl2.0))))

;; Dependency cycle
(define-public rust-mio
  (package
    (name "rust-mio")
    (version "0.6.4")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "mio" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "10g65mhc82mf4q01m4sibgxjqalpi4f04gs5ggkkd4w4kbabvkgf"))))
    (build-system cargo-build-system)
    (native-inputs
      `(("rust-bytes" ,rust-bytes "src")
        ("rust-env-logger" ,rust-env-logger "src")
        ("rust-tempdir" ,rust-tempdir "src")))
    (inputs
      `(("rust-lazycell" ,rust-lazycell "src")
        ("rust-libc" ,rust-libc "src")
        ("rust-log" ,rust-log "src")
        ("rust-net2" ,rust-net2 "src")
        ("rust-slab" ,rust-slab "src")))
    (home-page "https://github.com/carllerche/mio")
    (synopsis "Lightweight non-blocking IO")
    (description "This package provides lightweight non-blocking IO.")
    (license license:expat)))

(define-public rust-tokio
  (package
    (name "rust-tokio")
    (version "0.0.0") ; FIXME 0.1
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "tokio" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1qpyb5ncs57cb7g6m37m9ybxiwq22dzh8k22n39ifqc654hql05d"))))
    (build-system cargo-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'install 'delete-lock
           (lambda _
             (delete-file "Cargo.lock") ; Otherwise "cargo install" fails.
             #t)))))
    (home-page "")
    (synopsis "A fast, async, IO framework")
    (description "This package provides a fast, async, IO framework.")
    (license license:expat)))

;; Test failure.
(define-public rust-glob
 (package
  (name "rust-glob")
  (version "0.2.11")
  (source
    (origin
      (method url-fetch)
      (uri (crate-uri "glob" version))
      (file-name
        (string-append name "-" version ".tar.gz"))
      (sha256
        (base32
          "1ysvi72slkw784fcsymgj4308c3y03gwjjzqxp80xdjnkbh8vqcb"))))
  (build-system cargo-build-system)
  (propagated-inputs
   `(("rust-tempdir" ,rust-tempdir "src")))
  (home-page "https://github.com/rust-lang/glob")
  (synopsis "Matching file paths against Unix shell style patterns")
  (description "This package provides support for matching file paths against
Unix shell style patterns.")
  ;; Choose either license.
  (license (list license:expat license:asl2.0))))

; TODO mioco
; TOOD https://intermezzos.github.io/
; TODO http://os.phil-opp.com/ [!!!]
; good Rust: https://github.com/google/xi-editor
; good Rust: https://github.com/jwilm/alacritty
; good Rust: https://github.com/BurntSushi/ripgrep

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: Current state of cargo-build-system
  2019-01-23 17:10 ` Danny Milosavljevic
@ 2019-01-25 23:57   ` Ivan Petkov
  2019-01-27 23:13     ` Ivan Petkov
  2019-01-28  8:44     ` Ricardo Wurmus
  0 siblings, 2 replies; 8+ messages in thread
From: Ivan Petkov @ 2019-01-25 23:57 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Thank you all for the responses!

> Cycles.  Also, often Cargo.lock specifies exact versions of dependencies (in
> programs, at least)

Yes, this is pretty much the main issue I immediately hit when doing a naive
crate import, more on this further down.

> First, we'd have to find out what kind of things Cargo can build and how to
> detect it.

Cargo supports a subcommand called `metadata` which essentially dumps its
manifest in JSON format, which will include build scripts, binary outputs, etc.
I think this should give us enough information to figure out which packages have
targets to install (right now we try to install every single package which
doesn't work for libraries) among other things.

> After that, we can decide whether to compile libraries or just ship them as
> source (right now, we do the latter pretty often - almost everything in Guix
> Rust library packages ends up in the "src" output).
>  
> Getting the unit tests to run often requires breaking many cycles, so maybe
> skip that at first.

I tried breaking up cycles by hand for a couple days on another sample import,
but its just too tedious and error prone, especially when cycles span multiple
packages...  I'd really like for us to solve the issue altogether if possible.

Cargo (thankfully) checks and rejects an true dependency cycles, but its
notion of dev-dependencies (deps only used for running tests) is what throws
guix in for a loop. Dev-depencency cycles are permitted by cargo because it
builds the target crate independently, then it builds any extra dependencies
which may or may not depend on it, and then it builds a test crate which depends
on both. There are potentially legitimate cases which trigger this scenario
(such as testing your own public API through an upstream crate, see proc-macro2
for an example), or are just exacerbated by optional dependencies.

I think depending on the "src" output of crates is the right way to get things
started (this is what cargo essentially does anyway, it figures out what crates
are in the dependency, pulls their sources down and builds them), we can always
optimize this in the future to avoid recursively rebuilding crates over and
over.

However, it appears that guix still insists on building the entire package even
if we only depend on the "src" output. Is it possible to lazily build packages
based on the type of dependency? Is this something the build system can finagle,
or is this an inherent limitation to guix?

--Ivan

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

* Re: Current state of cargo-build-system
  2019-01-25 23:57   ` Ivan Petkov
@ 2019-01-27 23:13     ` Ivan Petkov
  2019-01-28  8:44     ` Ricardo Wurmus
  1 sibling, 0 replies; 8+ messages in thread
From: Ivan Petkov @ 2019-01-27 23:13 UTC (permalink / raw)
  To: guix-devel

Answering my own question after digging through the guix source, maybe someone
can correct me if I’ve gotten things wrong!

> On Jan 25, 2019, at 3:57 PM, Ivan Petkov <ivanppetkov@gmail.com> wrote:
> 
> However, it appears that guix still insists on building the entire package even
> if we only depend on the "src" output. Is it possible to lazily build packages
> based on the type of dependency? Is this something the build system can finagle,
> or is this an inherent limitation to guix?

So it appears that guix takes package definitions and feeds them to their
respective build system, which then get lowered to a bag (a more low-level
representation of a package). The bag is then built as the actual derivation.

Thus it is possible for the build system to do any kind of preprocessing of the
dependency closure or even produce dynamic/hidden packages if neccessary (but is
this discouraged?).

It also appears that guix expects to build the package entirely and it allows
the build system to split up the result into various outputs, but there isn't a
notion of lazily building out only the required outputs (I suppose the real
solution to this would be to break up the package definition in the appropriate
way to support this).

I have some ideas on how to resolve our cargo woes, namely by introducing
crate-source-only packages that don't actually get built and substitute those
for any potential cycles. I'd like to make imports and maintenance of package
definitions as simple as possible, so I'd like to explore making the build
system a bit more clever in handling this.

Will do some more prototyping on my own and report back!

--Ivan

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

* Re: Current state of cargo-build-system
  2019-01-25 23:57   ` Ivan Petkov
  2019-01-27 23:13     ` Ivan Petkov
@ 2019-01-28  8:44     ` Ricardo Wurmus
  2019-01-28 16:23       ` Ivan Petkov
  1 sibling, 1 reply; 8+ messages in thread
From: Ricardo Wurmus @ 2019-01-28  8:44 UTC (permalink / raw)
  To: Ivan Petkov; +Cc: guix-devel


Ivan Petkov <ivanppetkov@gmail.com> writes:

> However, it appears that guix still insists on building the entire package even
> if we only depend on the "src" output. Is it possible to lazily build packages
> based on the type of dependency? Is this something the build system can finagle,
> or is this an inherent limitation to guix?

Outputs are only generated when building the package.

If all you need is the source code, however, you can use (package-source
the-package) and use the resulting value as an input to another package.

--
Ricardo

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

* Re: Current state of cargo-build-system
  2019-01-28  8:44     ` Ricardo Wurmus
@ 2019-01-28 16:23       ` Ivan Petkov
  0 siblings, 0 replies; 8+ messages in thread
From: Ivan Petkov @ 2019-01-28 16:23 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel


> On Jan 28, 2019, at 12:44 AM, Ricardo Wurmus <rekado@elephly.net> wrote:
> 
> Outputs are only generated when building the package.
> 
> If all you need is the source code, however, you can use (package-source
> the-package) and use the resulting value as an input to another package.

Thanks Ricardo, I think this is what I was looking for!

In the case of cargo, I think it we still need to processes the input tarball into
the right format to get vendored correctly, but the build system should know enough
about how to perform the vendoring steps anyway, so this is a step in the right direction.

—Ivan

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

end of thread, other threads:[~2019-01-28 16:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21  0:11 Current state of cargo-build-system Ivan Petkov
2019-01-23 10:50 ` Ludovic Courtès
2019-01-23 11:46   ` ng0
2019-01-23 17:10 ` Danny Milosavljevic
2019-01-25 23:57   ` Ivan Petkov
2019-01-27 23:13     ` Ivan Petkov
2019-01-28  8:44     ` Ricardo Wurmus
2019-01-28 16:23       ` Ivan Petkov

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.