all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 00/12] Rust build system v2.
@ 2016-12-11 17:25 David Craven
  2016-12-11 17:25 ` [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f David Craven
                   ` (11 more replies)
  0 siblings, 12 replies; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

Here are my cleaned up rust patches. They aren't too useful yet
IMO. Patches 1-9 could be merged. rust-rand, cargo and the
recursive importer are for reference in case someone wants to play
with it.

David Craven (12):
  upstream: Use a the first url from urls when find2 returns #f.
  build-system: Add cargo build system.
  import: utils: Add some utilities.
  import: Add importer for rust crates.
  import: Add updater for rust crates.
  gnu: llvm: Enable install utils.
  gnu: Add rust bootstrap binaries.
  gnu: Add rustc.
  gnu: Add rust-libc.
  RECURSIVE IMPORTER wip
  gnu: Add rust-rand.
  gnu: Add cargo.

 Makefile.am                       |   3 +-
 doc/guix.texi                     |   5 +
 gnu/local.mk                      |   1 +
 gnu/packages/llvm.scm             |   3 +-
 gnu/packages/rust.scm             | 352 ++++++++++++++++++++++++++++++++++++++
 guix/build-system/cargo.scm       | 149 ++++++++++++++++
 guix/build/cargo-build-system.scm | 103 +++++++++++
 guix/import/crate.scm             | 219 ++++++++++++++++++++++++
 guix/import/utils.scm             |  43 +++++
 guix/scripts/import.scm           |   2 +-
 guix/scripts/import/crate.scm     |  94 ++++++++++
 guix/scripts/refresh.scm          |   4 +-
 guix/upstream.scm                 |   2 +-
 tests/crate.scm                   | 102 +++++++++++
 14 files changed, 1077 insertions(+), 5 deletions(-)
 create mode 100644 gnu/packages/rust.scm
 create mode 100644 guix/build-system/cargo.scm
 create mode 100644 guix/build/cargo-build-system.scm
 create mode 100644 guix/import/crate.scm
 create mode 100644 guix/scripts/import/crate.scm
 create mode 100644 tests/crate.scm

--
2.11.0

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

* [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 17:25   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 02/12] build-system: Add cargo build system David Craven
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* guix/upstream.scm (package-update): Use a url from the list when the
  find2 procedure doesn't find a url sig-url pair.
---
 guix/upstream.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/upstream.scm b/guix/upstream.scm
index 8685afd86..579942672 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -249,7 +249,7 @@ and 'interactive' (default)."
                              (string-suffix? archive-type url))
                            urls
                            (or signature-urls (circular-list #f)))))
-       (let ((tarball (download-tarball store url signature-url
+       (let ((tarball (download-tarball store (if url url (car urls)) signature-url
                                         #:key-download key-download)))
          (values version tarball))))
     (#f
-- 
2.11.0

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

* [PATCH 02/12] build-system: Add cargo build system.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
  2016-12-11 17:25 ` [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 17:26   ` Ludovic Courtès
  2016-12-30 11:08   ` Danny Milosavljevic
  2016-12-11 17:25 ` [PATCH 03/12] import: utils: Add some utilities David Craven
                   ` (9 subsequent siblings)
  11 siblings, 2 replies; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* guix/build-system/cargo.scm: New file.
* guix/build/cargo-build-system.scm: New file.
---
 guix/build-system/cargo.scm       | 149 ++++++++++++++++++++++++++++++++++++++
 guix/build/cargo-build-system.scm | 103 ++++++++++++++++++++++++++
 2 files changed, 252 insertions(+)
 create mode 100644 guix/build-system/cargo.scm
 create mode 100644 guix/build/cargo-build-system.scm

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
new file mode 100644
index 000000000..d6e7949e0
--- /dev/null
+++ b/guix/build-system/cargo.scm
@@ -0,0 +1,149 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
+;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system cargo)
+  #:use-module (guix search-paths)
+  #:use-module (guix store)
+  #:use-module (guix utils)
+  #:use-module (guix derivations)
+  #:use-module (guix packages)
+  #:use-module (guix build-system)
+  #:use-module (guix build-system gnu)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-26)
+  #:export (cargo-build-system
+            crate-url
+            crate-url?
+            crate-uri))
+
+(define crate-url "https://crates.io/api/v1/crates/")
+(define crate-url? (cut string-prefix? crate-url <>))
+
+(define (crate-uri name version)
+  "Return a URI string for the crate package hosted at crates.io corresponding
+to NAME and VERSION."
+  (string-append crate-url name "/" version "/download"))
+
+(define (default-cargo)
+  "Return the default Cargo package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((rust (resolve-interface '(gnu packages rust))))
+    (module-ref rust 'cargo-bootstrap)))
+
+(define (default-rustc)
+  "Return the default Rustc package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((rust (resolve-interface '(gnu packages rust))))
+    (module-ref rust 'rustc-bootstrap)))
+
+(define %cargo-build-system-modules
+  ;; Build-side modules imported by default.
+  `((guix build cargo-build-system)
+    ,@%gnu-build-system-modules))
+
+(define* (cargo-build store name inputs
+                      #:key
+                      (tests? #t)
+                      (test-target #f)
+                      (configure-flags #f)
+                      (phases '(@ (guix build cargo-build-system)
+                                  %standard-phases))
+                      (outputs '("out"))
+                      (search-paths '())
+                      (system (%current-system))
+                      (guile #f)
+                      (imported-modules %cargo-build-system-modules)
+                      (modules '((guix build cargo-build-system)
+                                 (guix build utils))))
+  "Build SOURCE using CARGO, and with INPUTS."
+
+  (define builder
+    `(begin
+       (use-modules ,@modules)
+       (cargo-build #:name ,name
+                    #:source ,(match (assoc-ref inputs "source")
+                                (((? derivation? source))
+                                 (derivation->output-path source))
+                                ((source)
+                                 source)
+                                (source
+                                 source))
+                    #:system ,system
+                    #:test-target ,test-target
+                    #:tests? ,tests?
+                    #:phases ,phases
+                    #:outputs %outputs
+                    #:search-paths ',(map search-path-specification->sexp
+                                          search-paths)
+                    #:inputs %build-inputs)))
+
+  (define guile-for-build
+    (match guile
+      ((? package?)
+       (package-derivation store guile system #:graft? #f))
+      (#f                                         ; the default
+       (let* ((distro (resolve-interface '(gnu packages commencement)))
+              (guile  (module-ref distro 'guile-final)))
+         (package-derivation store guile system #:graft? #f)))))
+
+  (build-expression->derivation store name builder
+                                #:inputs inputs
+                                #:system system
+                                #:modules imported-modules
+                                #:outputs outputs
+                                #:guile-for-build guile-for-build))
+
+(define* (lower name
+                #:key source inputs native-inputs outputs system target
+                (cargo (default-cargo))
+                (rustc (default-rustc))
+                #:allow-other-keys
+                #:rest arguments)
+  "Return a bag for NAME."
+
+  (define private-keywords
+    '(#:source #:target #:cargo #:rustc #:inputs #:native-inputs))
+
+  (and (not target) ;; TODO: support cross-compilation
+       (bag
+         (name name)
+         (system system)
+         (target target)
+         (host-inputs `(,@(if source
+                              `(("source" ,source))
+                              '())
+                        ,@inputs
+
+                        ;; Keep the standard inputs of 'gnu-build-system'
+                        ,@(standard-packages)))
+         (build-inputs `(("cargo" ,cargo)
+                         ("rustc" ,rustc)
+                         ,@native-inputs))
+         (outputs outputs)
+         (build (if target cargo-cross-build cargo-build))
+         (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define cargo-build-system
+  (build-system
+    (name 'cargo)
+    (description
+     "Cargo build system, to build Rust crates")
+    (lower lower)))
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
new file mode 100644
index 000000000..8428580fd
--- /dev/null
+++ b/guix/build/cargo-build-system.scm
@@ -0,0 +1,103 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build cargo-build-system)
+  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+  #:use-module (guix build utils)
+  #:use-module (ice-9 ftw)
+  #:use-module (ice-9 format)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
+  #:export (%standard-phases
+            cargo-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Rust package build procedure.
+;;
+;; Code:
+
+;; FIXME: Needs to be parsed from url not package name.
+(define (package-name->crate-name name)
+  "Return the crate name of NAME."
+  (match (string-split name #\-)
+    (("rust" rest ...)
+     (string-join rest "-"))
+    (_ #f)))
+
+(define* (configure #:key inputs #:allow-other-keys)
+  "Replace Cargo.toml [dependencies] section with guix inputs."
+  (let ((port (open-file "Cargo.toml" "a" #:encoding "utf-8")))
+    (format port "~%[replace]~%")
+    (for-each
+     (match-lambda
+       ((name . path)
+        (let ((crate (package-name->crate-name name)))
+          (when (and crate path)
+            (match (string-split (basename path) #\-)
+              ((_ ... version)
+               (format port "\"~a:~a\" = { path = \"~a/rustsrc\" }~%"
+                       crate version path)))))))
+     inputs)
+    (close-port port))
+  #t)
+
+(define* (build #:key (cargo-build-flags '("--release")) #:allow-other-keys)
+  "Build a given Cargo package."
+  (zero? (apply system* `("cargo" "build" ,@cargo-build-flags))))
+
+(define* (check #:key tests? #:allow-other-keys)
+  "Run tests for a given Cargo package."
+  (when tests?
+    (zero? (system* "cargo" "test"))))
+
+(define* (install #:key inputs outputs #:allow-other-keys)
+  "Install a given Cargo package."
+  (let* ((out (assoc-ref outputs "out"))
+         (src (assoc-ref inputs "source"))
+         (bin (string-append out "/bin"))
+         (rsrc (string-append out "/rustsrc")))
+    (mkdir-p rsrc)
+    ;; Rust doesn't have a stable ABI yet. Because of this
+    ;; Cargo doesn't have a search path for binaries yet.
+    ;; Until this changes we are working around this by
+    ;; distributing crates as source and replacing
+    ;; references in Cargo.toml with store paths.
+    (copy-recursively "src" (string-append rsrc "/src"))
+    (install-file "Cargo.toml" rsrc)
+    ;; When the package includes executables we install
+    ;; it using cargo install. This fails when the crate
+    ;; doesn't contain an executable.
+    (system* "cargo" "install" "--root" bin)
+    #t))
+
+(define %standard-phases
+  ;; 'configure' phase is not needed.
+  (modify-phases gnu:%standard-phases
+    (replace 'configure configure)
+    (replace 'build build)
+    (replace 'check check)
+    (replace 'install install)))
+
+(define* (cargo-build #:key inputs (phases %standard-phases)
+                      #:allow-other-keys #:rest args)
+  "Build the given Cargo package, applying all of PHASES in order."
+  (apply gnu:gnu-build #:inputs inputs #:phases phases args))
+
+;;; cargo-build-system.scm ends here
-- 
2.11.0

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

* [PATCH 03/12] import: utils: Add some utilities.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
  2016-12-11 17:25 ` [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f David Craven
  2016-12-11 17:25 ` [PATCH 02/12] build-system: Add cargo build system David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 17:29   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 04/12] import: Add importer for rust crates David Craven
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/import/utils.scm (json-fetch, maybe-inputs, maybe-native-inputs,
  package->definition): New variables.
---
 guix/import/utils.scm | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 057c2d9c7..e2e90676a 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -22,6 +22,8 @@
   #:use-module (guix base32)
   #:use-module ((guix build download) #:prefix build:)
   #:use-module (guix hash)
+  #:use-module (guix http-client)
+  #:use-module (json)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix utils)
   #:use-module (ice-9 match)
@@ -34,8 +36,13 @@
             assoc-ref*
 
             url-fetch
+            json-fetch
             guix-hash-url
 
+            maybe-inputs
+            maybe-native-inputs
+            package->definition
+
             spdx-string->license
             license->symbol
 
@@ -205,3 +212,39 @@ into a proper sentence and by using two spaces between sentences."
     ;; Use double spacing between sentences
     (regexp-substitute/global #f "\\. \\b"
                               cleaned 'pre ".  " 'post)))
+
+(define (package-names->package-inputs names)
+  (map (lambda (input)
+         (list input (list 'unquote (string->symbol input))))
+       names))
+
+(define (maybe-inputs package-names)
+  "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a
+package definition."
+  (match (package-names->package-inputs package-names)
+    (()
+     '())
+    ((package-inputs ...)
+     `((inputs (,'quasiquote ,package-inputs))))))
+
+(define (maybe-native-inputs package-names)
+  "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a
+package definition."
+  (match (package-names->package-inputs package-names)
+    (()
+     '())
+    ((package-inputs ...)
+     `((native-inputs (,'quasiquote ,package-inputs))))))
+
+(define* (json-fetch url)
+  "Return an alist representation of the url metadata."
+  (let* ((port (http-fetch url))
+         (result (json->scm port)))
+    (close-port port)
+    (hash-table->alist result)))
+
+(define (package->definition guix-package)
+  (match guix-package
+    (('package ('name (? string? name)) _ ...)
+     `(define-public ,(string->symbol name)
+        ,guix-package))))
-- 
2.11.0

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

* [PATCH 04/12] import: Add importer for rust crates.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (2 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 03/12] import: utils: Add some utilities David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 17:30   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 05/12] import: Add updater " David Craven
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* guix/import/crate.scm: New file.
* guix/scripts/import/crate.scm: New file.
* guix/scripts/import.scm (importers): Add crate importer.
* tests/crate.scm: New file.
* doc/guix.texi: Add crate importer to table.
---
 Makefile.am                   |   3 +-
 doc/guix.texi                 |   5 ++
 guix/import/crate.scm         | 124 ++++++++++++++++++++++++++++++++++++++++++
 guix/scripts/import.scm       |   2 +-
 guix/scripts/import/crate.scm |  94 ++++++++++++++++++++++++++++++++
 guix/scripts/refresh.scm      |   1 +
 tests/crate.scm               | 102 ++++++++++++++++++++++++++++++++++
 7 files changed, 329 insertions(+), 2 deletions(-)
 create mode 100644 guix/import/crate.scm
 create mode 100644 guix/scripts/import/crate.scm
 create mode 100644 tests/crate.scm

diff --git a/Makefile.am b/Makefile.am
index 0e3ddac14..e0f2a2f99 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -280,7 +280,8 @@ if HAVE_GUILE_JSON
 SCM_TESTS += 					\
   tests/pypi.scm				\
   tests/cpan.scm				\
-  tests/gem.scm
+  tests/gem.scm					\
+  tests/crate.scm
 
 endif
 
diff --git a/doc/guix.texi b/doc/guix.texi
index 0cb1bc766..971d8af63 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5267,6 +5267,11 @@ signatures,, emacs, The GNU Emacs Manual}).
 identifier.
 @end itemize
 @end table
+
+@item crate
+@cindex crate
+Import metadata from the crates.io rust package repository
+@uref{https://crates.io, crates.io}.
 @end table
 
 The structure of the @command{guix import} code is modular.  It would be
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
new file mode 100644
index 000000000..766b2a12c
--- /dev/null
+++ b/guix/import/crate.scm
@@ -0,0 +1,124 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import crate)
+  #:use-module (guix base32)
+  #:use-module (guix build-system cargo)
+  #:use-module ((guix download) #:prefix download:)
+  #:use-module (guix hash)
+  #:use-module (guix http-client)
+  #:use-module (guix import utils)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix monads)
+  #:use-module (guix packages)
+  #:use-module (guix upstream)
+  #:use-module (guix utils)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 pretty-print) ; recursive
+  #:use-module (json)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-2)
+  #:use-module (srfi srfi-26)
+  #:export (crate->guix-package
+            guix-package->crate-name))
+
+(define (crate-fetch crate-name callback)
+  "Fetch the metadata for CRATE-NAME from crates.io and call the callback."
+
+  (define (crates->inputs crates)
+    (sort (map (cut assoc-ref <> "crate_id") crates) string-ci<?))
+
+  (define (string->license string)
+    (map spdx-string->license (string-split string #\/)))
+
+  (define (crate-kind-predicate kind)
+    (lambda (dep) (string=? (assoc-ref dep "kind") kind)))
+
+  (and-let* ((crate-json (json-fetch (string-append crate-url crate-name)))
+             (crate (assoc-ref crate-json "crate"))
+             (name (assoc-ref crate "name"))
+             (version (assoc-ref crate "max_version"))
+             (home-page (assoc-ref crate "homepage"))
+             (synopsis (assoc-ref crate "description"))
+             (description (assoc-ref crate "description"))
+             (license (string->license (assoc-ref crate "license")))
+             (path (string-append "/" version "/dependencies"))
+             (deps-json (json-fetch (string-append crate-url name path)))
+             (deps (assoc-ref deps-json "dependencies"))
+             (input-crates (filter (crate-kind-predicate "normal") deps))
+             (native-input-crates
+              (filter (lambda (dep)
+                        (not ((crate-kind-predicate "normal") dep))) deps))
+             (inputs (crates->inputs input-crates))
+             (native-inputs (crates->inputs native-input-crates)))
+    (callback #:name name #:version version
+              #:inputs inputs #:native-inputs native-inputs
+              #:home-page home-page #:synopsis synopsis
+              #:description description #:license license)))
+
+(define* (make-crate-sexp #:key name version inputs native-inputs
+                          home-page synopsis description license
+                          #:allow-other-keys)
+  "Return the `package' s-expression for a rust package with the given NAME,
+VERSION, INPUTS, NATIVE-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
+  (let* ((port (http-fetch (crate-uri name version)))
+         (guix-name (crate-name->package-name name))
+         (inputs (map crate-name->package-name inputs))
+         (native-inputs (map crate-name->package-name native-inputs))
+         (pkg `(package
+                   (name ,guix-name)
+                   (version ,version)
+                   (source (origin
+                             (method url-fetch)
+                             (uri (crate-uri ,name version))
+                             (file-name (string-append name "-" version ".tar.gz"))
+                             (sha256
+                              (base32
+                               ,(bytevector->nix-base32-string (port-sha256 port))))))
+                   (build-system cargo-build-system)
+                   ,@(maybe-native-inputs native-inputs)
+                   ,@(maybe-inputs inputs)
+                   (home-page ,home-page)
+                   (synopsis ,synopsis)
+                   (description ,(beautify-description description))
+                   (license ,(match license
+                               (() #f)
+                               ((license) license)
+                               (_ `(list ,@license)))))))
+         (close-port port)
+         pkg))
+
+(define (crate->guix-package crate-name)
+  "Fetch the metadata for CRATE-NAME from crates.io, and return the
+`package' s-expression corresponding to that package, or #f on failure."
+  (crate-fetch crate-name make-crate-sexp))
+
+(define (guix-package->crate-name package)
+  "Return the crate name of PACKAGE."
+  (and-let* ((origin (package-source package))
+             (uri (origin-uri origin))
+             (crate-url? uri)
+             (len (string-length crate-url))
+             (path (xsubstring uri len))
+             (parts (string-split path #\/)))
+    (match parts
+      ((name _ ...) name))))
+
+(define (crate-name->package-name name)
+  (string-append "rust-" (string-join (string-split name #\_) "-")))
+
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index e54744fec..c67168604 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -73,7 +73,7 @@ rather than \\n."
 ;;; Entry point.
 ;;;
 
-(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "elpa" "gem" "cran"))
+(define importers '("gnu" "nix" "pypi" "cpan" "hackage" "elpa" "gem" "cran" "crate"))
 
 (define (resolve-importer name)
   (let ((module (resolve-interface
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
new file mode 100644
index 000000000..4337a0b62
--- /dev/null
+++ b/guix/scripts/import/crate.scm
@@ -0,0 +1,94 @@
+
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 David Thompson <davet@gnu.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts import crate)
+  #:use-module (guix ui)
+  #:use-module (guix utils)
+  #:use-module (guix scripts)
+  #:use-module (guix import crate)
+  #:use-module (guix scripts import)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-37)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
+  #:export (guix-import-crate))
+
+\f
+;;;
+;;; Command-line options.
+;;;
+
+(define %default-options
+  '())
+
+(define (show-help)
+  (display (_ "Usage: guix import crate PACKAGE-NAME
+Import and convert the crate.io package for PACKAGE-NAME.\n"))
+  (display (_ "
+  -h, --help             display this help and exit"))
+  (display (_ "
+  -V, --version          display version information and exit"))
+  (newline)
+  (show-bug-report-information))
+
+(define %options
+  ;; Specification of the command-line options.
+  (cons* (option '(#\h "help") #f #f
+                 (lambda args
+                   (show-help)
+                   (exit 0)))
+         (option '(#\V "version") #f #f
+                 (lambda args
+                   (show-version-and-exit "guix import crate")))
+         %standard-import-options))
+
+\f
+;;;
+;;; Entry point.
+;;;
+
+(define (guix-import-crate . args)
+  (define (parse-options)
+    ;; Return the alist of option values.
+    (args-fold* args %options
+                (lambda (opt name arg result)
+                  (leave (_ "~A: unrecognized option~%") name))
+                (lambda (arg result)
+                  (alist-cons 'argument arg result))
+                %default-options))
+
+  (let* ((opts (parse-options))
+         (args (filter-map (match-lambda
+                            (('argument . value)
+                             value)
+                            (_ #f))
+                           (reverse opts))))
+    (match args
+      ((package-name)
+       (let ((sexp (crate->guix-package package-name)))
+         (unless sexp
+           (leave (_ "failed to download meta-data for package '~a'~%")
+                  package-name))
+         sexp))
+      (()
+       (leave (_ "too few arguments~%")))
+      ((many ...)
+       (leave (_ "too many arguments~%"))))))
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 805e4543e..bcc11a2d2 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -39,6 +39,7 @@
                           %kernel.org-updater))
   #:use-module (guix import elpa)
   #:use-module (guix import cran)
+  #:use-module (guix import crate)
   #:use-module (guix import hackage)
   #:use-module (guix gnupg)
   #:use-module (gnu packages)
diff --git a/tests/crate.scm b/tests/crate.scm
new file mode 100644
index 000000000..18d5f72a8
--- /dev/null
+++ b/tests/crate.scm
@@ -0,0 +1,102 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 David Thompson <davet@gnu.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-crate)
+  #:use-module (guix import crate)
+  #:use-module (guix base32)
+  #:use-module (guix build-system cargo)
+  #:use-module (guix hash)
+  #:use-module (guix tests)
+  #:use-module (ice-9 iconv)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-64))
+
+(define test-crate
+  "{
+  \"crate\": {
+    \"max_version\": \"1.0.0\",
+    \"name\": \"foo\",
+    \"license\": \"MIT/Apache-2.0\",
+    \"description\": \"summary\",
+    \"homepage\": \"http://example.com\",
+  }
+}")
+
+(define test-dependencies
+  "{
+  \"dependencies\": [
+     {
+       \"crate_id\": \"bar\",
+       \"kind\": \"normal\",
+     }
+  ]
+}")
+
+(define test-source-hash
+  "")
+
+(test-begin "crate")
+
+(test-equal "guix-package->crate-name"
+  "rustc-serialize"
+  (guix-package->crate-name
+   (dummy-package
+    "rust-rustc-serialize"
+    (source (dummy-origin
+     (uri (crate-uri "rustc-serialize" "1.0")))))))
+
+(test-assert "crate->guix-package"
+  ;; Replace network resources with sample data.
+  (mock ((guix http-client) http-fetch
+         (lambda (url)
+           (match url
+             ("https://crates.io/api/v1/crates/foo"
+              (open-input-string test-crate))
+             ("https://crates.io/api/v1/crates/foo/1.0.0/download"
+              (set! test-source-hash
+                (bytevector->nix-base32-string
+                 (sha256 (string->bytevector "empty file\n" "utf-8"))))
+              (open-input-string "empty file\n"))
+             ("https://crates.io/api/v1/crates/foo/1.0.0/dependencies"
+              (open-input-string test-dependencies))
+             (_ (error "Unexpected URL: " url)))))
+    (match (crate->guix-package "foo")
+      (('package
+         ('name "rust-foo")
+         ('version "1.0.0")
+         ('source ('origin
+                    ('method 'url-fetch)
+                    ('uri ('crate-uri "foo" 'version))
+                    ('file-name ('string-append 'name "-" 'version ".tar.gz"))
+                    ('sha256
+                     ('base32
+                      (? string? hash)))))
+         ('build-system 'cargo-build-system)
+         ('inputs
+          ('quasiquote
+           (("rust-bar" ('unquote 'rust-bar)))))
+         ('home-page "http://example.com")
+         ('synopsis "summary")
+         ('description "summary")
+         ('license ('list 'license:expat 'license:asl2.0)))
+       (string=? test-source-hash hash))
+      (x
+       (pk 'fail x #f)))))
+
+(test-end "crate")
-- 
2.11.0

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

* [PATCH 05/12] import: Add updater for rust crates.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (3 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 04/12] import: Add importer for rust crates David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 17:30   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 06/12] gnu: llvm: Enable install utils David Craven
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* guix/import/crate.scm (crate-package?, latest-release,
  %crate-updater): New variables.
* guix/scripts/refresh.scm (%updaters): Add crate updater.
---
 guix/import/crate.scm    | 36 +++++++++++++++++++++++++++++++++++-
 guix/scripts/refresh.scm |  3 ++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 766b2a12c..45d5bf846 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -35,7 +35,8 @@
   #:use-module (srfi srfi-2)
   #:use-module (srfi srfi-26)
   #:export (crate->guix-package
-            guix-package->crate-name))
+            guix-package->crate-name
+            %crate-updater))
 
 (define (crate-fetch crate-name callback)
   "Fetch the metadata for CRATE-NAME from crates.io and call the callback."
@@ -122,3 +123,36 @@ VERSION, INPUTS, NATIVE-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
 (define (crate-name->package-name name)
   (string-append "rust-" (string-join (string-split name #\_) "-")))
 
+;;;
+;;; Updater
+;;;
+
+(define (crate-package? package)
+  "Return true if PACKAGE is a Rust crate from crates.io."
+  (let ((source-url (and=> (package-source package) origin-uri))
+        (fetch-method (and=> (package-source package) origin-method)))
+    (and (eq? fetch-method download:url-fetch)
+         (match source-url
+           ((? string?)
+            (crate-url? source-url))
+           ((source-url ...)
+            (any crate-url? source-url))))))
+
+(define (latest-release package)
+  "Return an <upstream-source> for the latest release of PACKAGE."
+  (let* ((crate-name (guix-package->crate-name package))
+         (callback (lambda* (#:key version #:allow-other-keys) version))
+         (version (crate-fetch crate-name callback))
+         (url (crate-uri crate-name version)))
+    (upstream-source
+     (package (package-name package))
+     (version version)
+     (urls (list url)))))
+
+(define %crate-updater
+  (upstream-updater
+   (name 'crates)
+   (description "Updater for crates.io packages")
+   (pred crate-package?)
+   (latest latest-release)))
+
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index bcc11a2d2..3d495963c 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -209,7 +209,8 @@ unavailable optional dependencies such as Guile-JSON."
                  %hackage-updater
                  ((guix import pypi) => %pypi-updater)
                  ((guix import gem) => %gem-updater)
-                 ((guix import github) => %github-updater)))
+                 ((guix import github) => %github-updater)
+                 ((guix import crate) => %crate-updater)))
 
 (define (lookup-updater-by-name name)
   "Return the updater called NAME."
-- 
2.11.0

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

* [PATCH 06/12] gnu: llvm: Enable install utils.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (4 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 05/12] import: Add updater " David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:50   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 07/12] gnu: Add rust bootstrap binaries David Craven
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/llvm.scm (llvm)[arguments]: Add -DLLVM_INStALL_UTILS=ON
  to configure-flags.
---
 gnu/packages/llvm.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 96679bf97..c425108c9 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -60,7 +60,8 @@
      `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
                            "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
                            "-DBUILD_SHARED_LIBS:BOOL=TRUE"
-                           "-DLLVM_ENABLE_FFI:BOOL=TRUE")
+                           "-DLLVM_ENABLE_FFI:BOOL=TRUE"
+                           "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
 
        ;; Don't use '-g' during the build, to save space.
        #:build-type "Release"
-- 
2.11.0

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

* [PATCH 07/12] gnu: Add rust bootstrap binaries.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (5 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 06/12] gnu: llvm: Enable install utils David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:44   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 08/12] gnu: Add rustc David Craven
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/rust.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add rust.scm.
---
 gnu/local.mk          |   1 +
 gnu/packages/rust.scm | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 191 insertions(+)
 create mode 100644 gnu/packages/rust.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 98a7f65ca..246057f69 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -321,6 +321,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/rsync.scm			\
   %D%/packages/ruby.scm				\
   %D%/packages/rush.scm				\
+  %D%/packages/rust.scm				\
   %D%/packages/samba.scm			\
   %D%/packages/sawfish.scm			\
   %D%/packages/scanner.scm			\
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
new file mode 100644
index 000000000..34f87c689
--- /dev/null
+++ b/gnu/packages/rust.scm
@@ -0,0 +1,190 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages rust)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bootstrap)
+  #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages elf)
+  #:use-module (gnu packages gcc)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
+  #:use-module (guix download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-26))
+
+;; Should be one less than the current released version.
+(define %rust-bootstrap-binaries-version "1.12.1")
+
+(define %rust-bootstrap-binaries
+  (origin
+    (method url-fetch)
+    (uri (string-append
+          "https://static.rust-lang.org/dist/"
+          ;; TODO: Maybe use the i686 binary for bootstrapping rustc on i686 and
+          ;; x86_64 to minimize the number binaries.
+          "rust-" %rust-bootstrap-binaries-version
+          "-x86_64-unknown-linux-gnu.tar.gz"))
+    (sha256
+     (base32
+      ;; 1.13.0 "1vaicmm0z6wlqdhshry14mfqgayp5n9pxs31h41w26mqn5rc7x4m"
+      "0k4qz7d0vd7z2sm4z7lpdhaaz9gbcx78yv6qladl52g32gn6lm4y"))))
+
+(define (increment-rust-version rust-version major patch)
+  (match (string-split rust-version #\.)
+    (("1" minor _)
+     (string-append (number->string major) "."
+                    (number->string (+ (string->number minor) 1)) "."
+                    (number->string patch)))))
+
+(define* (cargo-version rustc-version #:optional (patch 0))
+  ;; Computes the cargo version that matches the rustc version.
+  ;; https://github.com/rust-lang/cargo#Releases
+  (increment-rust-version rustc-version 0 patch))
+
+(define* (rustc-version bootstrap-version #:optional (patch 0))
+  ;; Computes the rustc version that can be compiled from a given
+  ;; other rustc version. The patch argument is for selecting
+  ;; a stability or security fix. 1.11.0 -> 1.12.1 -> 1.13.0
+  (increment-rust-version bootstrap-version 1 patch))
+
+(define (system->rust-platform system)
+  (cond
+   ((string-prefix? "x86_64" system) "x86_64-unknown-linux-gnu")
+   ((string-prefix? "i686" system) "i686-unknown-linux-gnu")
+   (else #f)))
+
+(define-public rustc-bootstrap
+  (package
+    (name "rustc-bootstrap")
+    (version %rust-bootstrap-binaries-version)
+    (source %rust-bootstrap-binaries)
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("patchelf" ,patchelf)))
+    (inputs
+     ;; FIXME: Use system gcc:lib. Does gcc "lib" need to be
+     ;; added to %final-inputs?
+     `(("gcc:lib" ,gcc "lib")
+       ("zlib" ,zlib)))
+    (arguments
+     `(#:tests? #f
+       #:strip-binaries? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (delete 'build)
+         (replace 'install
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (gcc (assoc-ref inputs "gcc"))
+                    (gcc:lib (assoc-ref inputs "gcc:lib"))
+                    (libc (assoc-ref inputs "libc"))
+                    (zlib (assoc-ref inputs "zlib"))
+                    (platform ,(system->rust-platform (%current-system)))
+                    (ld-so (string-append (assoc-ref inputs "libc")
+                                          ,(glibc-dynamic-linker)))
+                    (rpath (string-append out "/lib:" zlib "/lib:"
+                                          libc "/lib:" gcc:lib "/lib"))
+                    (rustc (string-append out "/bin/rustc"))
+                    (rustdoc (string-append out "/bin/rustdoc")))
+               (system* "bash" "install.sh"
+                        (string-append "--prefix=" out)
+                        (string-append "--components=rustc,"
+                                       "rust-std-" platform))
+               (for-each (lambda (file)
+                           (system* "patchelf" "--set-rpath" rpath file))
+                         (cons* rustc rustdoc (find-files out "\\.so$")))
+               (for-each (lambda (file)
+                           (system* "patchelf" "--set-interpreter" ld-so file))
+                         (list rustc rustdoc))
+               ;; Rust requires a gcc toolchain for linking. It
+               ;; looks for a compiler named cc in it's path. This
+               ;; can probably be configured during the build.
+               (symlink (string-append gcc "/bin/gcc")
+                        (string-append out "/bin/cc"))))))))
+    (home-page "https://www.rust-lang.org")
+    (synopsis "Rustc bootstrap")
+    (description "This package prepares the rustc binary for bootstrapping
+the rustc package.")
+    (license license:asl2.0)))
+
+(define-public cargo-bootstrap
+  (package
+    (name "cargo-bootstrap")
+    (version (cargo-version %rust-bootstrap-binaries-version))
+    (source %rust-bootstrap-binaries)
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("patchelf" ,patchelf)))
+    (inputs
+     ;; FIXME: See rustc-bootstrap.
+     `(("gcc:lib" ,gcc "lib")))
+    (arguments
+     `(#:tests? #f
+       #:strip-binaries? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (delete 'build)
+         (replace 'install
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (platform ,(system->rust-platform (%current-system)))
+                    (gcc:lib (assoc-ref inputs "gcc:lib"))
+                    (libc (assoc-ref inputs "libc"))
+                    (ld-so (string-append libc ,(glibc-dynamic-linker)))
+                    (rpath (string-append out "/lib:" libc "/lib:"
+                                          gcc:lib "/lib"))
+                    (cargo (string-append out "/bin/cargo")))
+               (system* "bash" "install.sh"
+                        (string-append "--prefix=" out)
+                        "--components=cargo")
+               (system* "patchelf"
+                        "--set-interpreter" ld-so
+                        "--set-rpath" rpath
+                        cargo)))))))
+    (home-page "https://www.rust-lang.org")
+    (synopsis "Cargo bootstrap")
+    (description "This package prepares the cargo binary for bootstrapping
+the cargo package and it's dependencies.  When rustc is build using the new
+rustbuild build system it also requires cargo.  The gnu build system is going
+to be deprecated.")
+    (license license:asl2.0)))
+
+(define-public rust-bootstrap
+  (package
+    (name "rust-bootstrap")
+    (version %rust-bootstrap-binaries-version)
+    (source #f)
+    (build-system trivial-build-system)
+    (propagated-inputs
+     ;; XXX: guix size shows a size of zero. Are propagated inputs not
+     ;; counted?
+     `(("rustc-bootstrap" ,rustc-bootstrap)
+       ("cargo-bootstrap" ,cargo-bootstrap)))
+    (arguments
+     `(#:builder
+       (begin (mkdir (assoc-ref %outputs "out")))))
+    (home-page "https://www.rust-lang.org")
+    (synopsis "Rust bootstrap")
+    (description "Meta package for rustc and cargo bootstrap packages.")
+    (license license:asl2.0)))
-- 
2.11.0

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

* [PATCH 08/12] gnu: Add rustc.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (6 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 07/12] gnu: Add rust bootstrap binaries David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:47   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 09/12] gnu: Add rust-libc David Craven
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/rust.scm (rustc): New variable.

Co-authored-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
 gnu/packages/rust.scm | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 34f87c689..8bbb5d116 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -23,6 +23,10 @@
   #:use-module (gnu packages compression)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages jemalloc)
+  #:use-module (gnu packages llvm)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages version-control)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
@@ -188,3 +192,80 @@ to be deprecated.")
     (synopsis "Rust bootstrap")
     (description "Meta package for rustc and cargo bootstrap packages.")
     (license license:asl2.0)))
+
+(define-public rustc
+  (package
+    (name "rustc")
+    (version (rustc-version %rust-bootstrap-binaries-version))
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://static.rust-lang.org/dist/"
+                    "rustc-" version "-src.tar.gz"))
+              (sha256
+               (base32
+                "112h7qgbn8c7s5880vplpgy5n58sc8css32dq7z5wylpr9slgf7c"))))
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("cmake" ,cmake)
+       ("git" ,git)
+       ("python-2" ,python-2)
+       ("rustc-bootstrap" ,rustc-bootstrap)
+       ("which" ,which)))
+    (inputs
+     `(("jemalloc" ,jemalloc)
+       ("llvm" ,llvm)))
+    (arguments
+     ;; FIXME: Test failure with llvm 3.8; Update llvm.
+     ;; https://github.com/rust-lang/rust/issues/36835
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-configure
+           (lambda _
+             ;; Detect target CPU correctly.
+             (substitute* "configure"
+               (("/usr/bin/env") (which "env")))
+             ;; Avoid curl as a build dependency.
+             (substitute* "configure"
+               (("probe_need CFG_CURL curl") ""))))
+         (add-after 'unpack 'set-env
+           (lambda _
+             (setenv "RUSTC_BOOTSTRAP" "1")
+             (setenv "VERBOSE" "1")
+             (setenv "SHELL" (which "sh"))
+             (setenv "CONFIG_SHELL" (which "sh"))))
+         (add-after 'unpack 'patch-lockfile-test
+           (lambda _
+             (substitute* "src/tools/tidy/src/main.rs"
+               (("^.*cargo.*::check.*$") ""))))
+         (replace 'configure
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (gcc (assoc-ref inputs "gcc"))
+                    (python (assoc-ref inputs "python-2"))
+                    (rustc (assoc-ref inputs "rustc-bootstrap"))
+                    (llvm (assoc-ref inputs "llvm"))
+                    (jemalloc (assoc-ref inputs "jemalloc"))
+                    (flags (list
+                            (string-append "--prefix=" out)
+                            (string-append "--datadir=" out "/share")
+                            (string-append "--infodir=" out "/share/info")
+                            (string-append "--default-linker=" gcc "/bin/gcc")
+                            (string-append "--default-ar=" gcc "/bin/ar")
+                            (string-append "--python=" python "/bin/python2")
+                            (string-append "--local-rust-root=" rustc)
+                            (string-append "--llvm-root=" llvm)
+                            (string-append "--jemalloc-root=" jemalloc "/lib")
+                            "--release-channel=stable"
+                            "--enable-rpath"
+                            "--enable-local-rust"
+                            ;;"--enable-rustbuild"
+                            "--disable-manage-submodules")))
+               ;; Rust uses a custom configure script (no autoconf).
+               (zero? (apply system* "./configure" flags))))))))
+    (synopsis "Compiler for the Rust progamming language")
+    (description "Rust is a systems programming language that runs blazingly
+fast, prevents segfaults, and guarantees thread safety.")
+    (home-page "https://www.rust-lang.org")
+    (license (list license:asl2.0 license:expat))))
-- 
2.11.0

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

* [PATCH 09/12] gnu: Add rust-libc.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (7 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 08/12] gnu: Add rustc David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:48   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 10/12] RECURSIVE IMPORTER wip David Craven
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/rust.scm (rust-libc): New variable.
---
 gnu/packages/rust.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 8bbb5d116..acff15e6f 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -27,6 +27,7 @@
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages python)
   #:use-module (gnu packages version-control)
+  #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
@@ -269,3 +270,22 @@ to be deprecated.")
 fast, prevents segfaults, and guarantees thread safety.")
     (home-page "https://www.rust-lang.org")
     (license (list license:asl2.0 license:expat))))
+
+(define-public rust-libc
+  (package
+    (name "rust-libc")
+    (version "0.2.16")
+    (source (origin
+              (method url-fetch)
+              (uri (crate-uri "libc" version))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "139fl308mb5wxap5fyd5c7n779a60sc1fi8wgdv0zvihrv519020"))))
+    (build-system cargo-build-system)
+    (home-page "https://github.com/rust-lang/libc")
+    (synopsis
+     "Types and bindings to native C functions")
+    (description "This package provides a library for types and bindings to
+native C functions often found in libc or other common platform libraries.")
+    (license (list license:expat license:asl2.0))))
-- 
2.11.0

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

* [PATCH 10/12] RECURSIVE IMPORTER wip
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (8 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 09/12] gnu: Add rust-libc David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:49   ` Ludovic Courtès
  2016-12-11 17:25 ` [PATCH 11/12] gnu: Add rust-rand David Craven
  2016-12-11 17:25 ` [PATCH 12/12] gnu: Add cargo David Craven
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

---
 guix/import/crate.scm | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 45d5bf846..632c35f0a 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -156,3 +156,64 @@ VERSION, INPUTS, NATIVE-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
    (pred crate-package?)
    (latest latest-release)))
 
+;;;
+;;; Recursive importer
+;;;
+
+(define-public (recursive-import crate-name)
+  (define (crate-inputs crate-name)
+    (crate-fetch
+     crate-name
+     (lambda* (#:key inputs native-inputs #:allow-other-keys)
+       (append inputs native-inputs))))
+
+  (define (crate->input-list crate-name crate-list)
+    (let ((crates (cons crate-name crate-list))
+          (inputs (crate-inputs crate-name)))
+      (for-each
+       (lambda (crate)
+         (when (not (member crate crates))
+           (format #t "Needs ~s crate.~%" crate)
+           (set! crates (crate->input-list crate crates))))
+       inputs)
+      crates))
+
+  (define (recursive-crate-inputs crate-name)
+    (crate->input-list crate-name '()))
+
+  (and-let* ((crates (recursive-crate-inputs crate-name))
+             (crates-sorted (sort crates string<?))
+             (packages (map crate->guix-package crates-sorted))
+             (definitions (map package->definition packages)))
+    (for-each
+     (lambda (expr)
+       (pretty-print expr (newline-rewriting-port
+                           (current-output-port))))
+     definitions)))
+
+
+(define (newline-rewriting-port output)
+  "Return an output port that rewrites strings containing the \\n escape
+to an actual newline.  This works around the behavior of `pretty-print'
+and `write', which output these as \\n instead of actual newlines,
+whereas we want the `description' field to contain actual newlines
+rather than \\n."
+  (define (write-string str)
+    (let loop ((chars (string->list str)))
+      (match chars
+        (()
+         #t)
+        ((#\\ #\n rest ...)
+         (newline output)
+         (loop rest))
+        ((chr rest ...)
+         (write-char chr output)
+         (loop rest)))))
+
+  (make-soft-port (vector (cut write-char <>)
+                          write-string
+                          (lambda _ #t)           ; flush
+                          #f
+                          (lambda _ #t)           ; close
+                          #f)
+                  "w"))
-- 
2.11.0

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

* [PATCH 11/12] gnu: Add rust-rand.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (9 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 10/12] RECURSIVE IMPORTER wip David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:50   ` Ludovic Courtès
  2017-01-03  0:52   ` Danny Milosavljevic
  2016-12-11 17:25 ` [PATCH 12/12] gnu: Add cargo David Craven
  11 siblings, 2 replies; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/rust.scm (rust-rand): New variable.
---
 gnu/packages/rust.scm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index acff15e6f..a64f72f03 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -289,3 +289,22 @@ fast, prevents segfaults, and guarantees thread safety.")
     (description "This package provides a library for types and bindings to
 native C functions often found in libc or other common platform libraries.")
     (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)
+    (inputs
+     `(("rust-libc" ,rust-libc)))
+    (home-page "https://github.com/rust-lang/rand")
+    (synopsis "Random number generators")
+    (description "Random number generators and other randomness functionality.")
+    (license (list license:expat license:asl2.0))))
-- 
2.11.0

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

* [PATCH 12/12] gnu: Add cargo.
  2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
                   ` (10 preceding siblings ...)
  2016-12-11 17:25 ` [PATCH 11/12] gnu: Add rust-rand David Craven
@ 2016-12-11 17:25 ` David Craven
  2016-12-13 22:51   ` Ludovic Courtès
  11 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-11 17:25 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/rust.scm (cargo): New variable.
---
 gnu/packages/rust.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index a64f72f03..dfe0db60e 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -19,13 +19,18 @@
 (define-module (gnu packages rust)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bootstrap)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages curl)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages jemalloc)
   #:use-module (gnu packages llvm)
+  #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages ssh)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
@@ -271,6 +276,43 @@ fast, prevents segfaults, and guarantees thread safety.")
     (home-page "https://www.rust-lang.org")
     (license (list license:asl2.0 license:expat))))
 
+(define-public cargo
+  ;; NOTE: To build cargo manually:
+  ;; cd /tmp && tar -xf $(guix build -S cargo)
+  ;; cd cargo*
+  ;; guix environment cargo
+  ;; cargo build --release
+  (package
+    (name "cargo")
+    (version (cargo-version (rustc-version %rust-bootstrap-binaries-version)))
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/rust-lang/cargo"
+                    "/archive/" version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0cbm32dw85zqf84yk2bvld5ggdkxlndn8kp3wri9z5c68mj0xv4h"))))
+    (build-system cargo-build-system)
+    (inputs
+     `(("cmake" ,cmake)
+       ("curl" ,curl)
+       ("libgit2" ,libgit2)
+       ("libssh2" ,libssh2)
+       ("openssl" ,openssl)
+       ("pkg-config" ,pkg-config)
+       ("python-2" ,python-2)
+       ("rust-bootstrap" ,rust-bootstrap)
+       ("zlib" ,zlib)))
+    (home-page "https://github.com/rust-lang/cargo")
+    (synopsis "Build tool and package manager for Rust")
+    (description "Cargo downloads your Rust project’s dependencies and compiles
+your project.")
+    ;; Cargo is dual licensed Apache and MIT. Also contains
+    ;; code from openssl which is GPL2 with linking exception.
+    (license (list license:asl2.0 license:expat license:gpl2+))))
+
 (define-public rust-libc
   (package
     (name "rust-libc")
-- 
2.11.0

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

* Re: [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f.
  2016-12-11 17:25 ` [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f David Craven
@ 2016-12-13 17:25   ` Ludovic Courtès
  2016-12-13 20:07     ` David Craven
  0 siblings, 1 reply; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 17:25 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * guix/upstream.scm (package-update): Use a url from the list when the
>   find2 procedure doesn't find a url sig-url pair.
> ---
>  guix/upstream.scm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/guix/upstream.scm b/guix/upstream.scm
> index 8685afd86..579942672 100644
> --- a/guix/upstream.scm
> +++ b/guix/upstream.scm
> @@ -249,7 +249,7 @@ and 'interactive' (default)."
>                               (string-suffix? archive-type url))
>                             urls
>                             (or signature-urls (circular-list #f)))))
> -       (let ((tarball (download-tarball store url signature-url
> +       (let ((tarball (download-tarball store (if url url (car urls)) signature-url

Please make it (or url (first urls)).

Could it be that commit 8d5d06282e255557d3bdda1794bd3fea2c84ff59 made it
moot?  What are the faulty values for ‘urls’ and ‘signature-urls’ that
trigger the problem?

Thanks, and sorry for taking long for just one line!

Ludo’.

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

* Re: [PATCH 02/12] build-system: Add cargo build system.
  2016-12-11 17:25 ` [PATCH 02/12] build-system: Add cargo build system David Craven
@ 2016-12-13 17:26   ` Ludovic Courtès
  2016-12-30 11:08   ` Danny Milosavljevic
  1 sibling, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 17:26 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * guix/build-system/cargo.scm: New file.
> * guix/build/cargo-build-system.scm: New file.

Along with gnu/local.mk please.  OK with this change!

Ludo’.

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

* Re: [PATCH 03/12] import: utils: Add some utilities.
  2016-12-11 17:25 ` [PATCH 03/12] import: utils: Add some utilities David Craven
@ 2016-12-13 17:29   ` Ludovic Courtès
  2016-12-13 18:09     ` David Craven
  0 siblings, 1 reply; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 17:29 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/import/utils.scm (json-fetch, maybe-inputs, maybe-native-inputs,
    ^^^
guix/

>   package->definition): New variables.

IIRC there was an argument against adding ‘json-fetch’ in this module
earlier this year, because that would make Guile-JSON mandatory.  Could

If you can leave that bit out, that LGTM!

Thanks,
Ludo’.

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

* Re: [PATCH 04/12] import: Add importer for rust crates.
  2016-12-11 17:25 ` [PATCH 04/12] import: Add importer for rust crates David Craven
@ 2016-12-13 17:30   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 17:30 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * guix/import/crate.scm: New file.
> * guix/scripts/import/crate.scm: New file.
> * guix/scripts/import.scm (importers): Add crate importer.
> * tests/crate.scm: New file.
> * doc/guix.texi: Add crate importer to table.

Please add the new files in Makefile.am, local.mk, etc.

Other than that LGTM, thanks!

Ludo’.

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

* Re: [PATCH 05/12] import: Add updater for rust crates.
  2016-12-11 17:25 ` [PATCH 05/12] import: Add updater " David Craven
@ 2016-12-13 17:30   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 17:30 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * guix/import/crate.scm (crate-package?, latest-release,
>   %crate-updater): New variables.
> * guix/scripts/refresh.scm (%updaters): Add crate updater.

Please add a line under “Invoking guix refresh” in guix.texi, like we
did for the other updaters.

OK with this change!

Ludo’.

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

* Re: [PATCH 03/12] import: utils: Add some utilities.
  2016-12-13 17:29   ` Ludovic Courtès
@ 2016-12-13 18:09     ` David Craven
  0 siblings, 0 replies; 31+ messages in thread
From: David Craven @ 2016-12-13 18:09 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

> IIRC there was an argument against adding ‘json-fetch’ in this module
> earlier this year, because that would make Guile-JSON mandatory.

Yep. This is a mistake. I thought that you suggested using http-fetch
to avoid pulling in guile-json, but that was because of the temporary
file thing. I think Eric already pushed a patch for this...

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

* Re: [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f.
  2016-12-13 17:25   ` Ludovic Courtès
@ 2016-12-13 20:07     ` David Craven
  2016-12-13 22:22       ` Ludovic Courtès
  0 siblings, 1 reply; 31+ messages in thread
From: David Craven @ 2016-12-13 20:07 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

> Thanks, and sorry for taking long for just one line!

No problem. That's what code reviews are for...

I removed my change and inserted
       (display urls)
       (display signature-urls)
       (display url)
       (display signature-url)

here are the results:

urls: (https://crates.io/api/v1/crates/libc/0.2.18/download)
signature-urls: #f
url: #f
signature-url: #f

Backtrace:
In ice-9/boot-9.scm:
 157: 19 [catch #t #<catch-closure 24a64a0> ...]
In unknown file:
   ?: 18 [apply-smob/1 #<catch-closure 24a64a0>]
In ice-9/boot-9.scm:
  63: 17 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 16 [eval # #]
In ice-9/boot-9.scm:
2401: 15 [save-module-excursion #<procedure 24c7940 at
ice-9/boot-9.scm:4045:3 ()>]
4050: 14 [#<procedure 24c7940 at ice-9/boot-9.scm:4045:3 ()>]
1724: 13 [%start-stack load-stack ...]
1729: 12 [#<procedure 24ddcf0 ()>]
In unknown file:
   ?: 11 [primitive-load "/home/dvc/guix/scripts/guix"]
In guix/ui.scm:
1222: 10 [run-guix-command refresh "-u" "rust-libc"]
In ice-9/boot-9.scm:
 157: 9 [catch srfi-34 #<procedure 6ddaa20 at guix/ui.scm:426:2 ()> ...]
 157: 8 [catch system-error ...]
In guix/scripts/refresh.scm:
 442: 7 [#<procedure 6c523c0 at guix/scripts/refresh.scm:441:4 ()>]
 454: 6 [#<procedure 6c72d80 at guix/scripts/refresh.scm:442:6 ()>]
In srfi/srfi-1.scm:
 619: 5 [for-each #<procedure 6c65c00 at
guix/scripts/refresh.scm:455:15 (t-22335)> ...]
In guix/scripts/refresh.scm:
 263: 4 [update-package # # # ...]
In ice-9/eval.scm:
 411: 3 [eval # #]
 411: 2 [eval # #]
In guix/download.scm:
 507: 1 [download-to-store #<build-daemon 256.15 6c65cc0> #f ...]
In unknown file:
   ?: 0 [basename #f #<undefined>]

ERROR: In procedure basename:
ERROR: In procedure scm_to_utf8_stringn: Wrong type argument in
position 1 (expecting string): #f

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

* Re: [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f.
  2016-12-13 20:07     ` David Craven
@ 2016-12-13 22:22       ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:22 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

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

David Craven <david@craven.ch> skribis:

>> Thanks, and sorry for taking long for just one line!
>
> No problem. That's what code reviews are for...
>
> I removed my change and inserted
>        (display urls)
>        (display signature-urls)
>        (display url)
>        (display signature-url)
>
> here are the results:
>
> urls: (https://crates.io/api/v1/crates/libc/0.2.18/download)
> signature-urls: #f
> url: #f
> signature-url: #f

Got it.  What about this change:


[-- Attachment #2: Type: text/x-patch, Size: 1169 bytes --]

diff --git a/guix/upstream.scm b/guix/upstream.scm
index 8685afd..e069cc2 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -241,12 +241,16 @@ and 'interactive' (default)."
                    ((archive-type)
                     (match (and=> (package-source package) origin-uri)
                       ((? string? uri)
-                       (or (file-extension uri) "gz"))
+                       (file-extension uri))
                       (_
                        "gz")))
                    ((url signature-url)
                     (find2 (lambda (url sig-url)
-                             (string-suffix? archive-type url))
+                             ;; Some URIs lack a file extension, like
+                             ;; 'https://crates.io/…/0.1/download'.  In that
+                             ;; case, pick the first URL.
+                             (or (not archive-type)
+                                 (string-suffix? archive-type url)))
                            urls
                            (or signature-urls (circular-list #f)))))
        (let ((tarball (download-tarball store url signature-url

[-- Attachment #3: Type: text/plain, Size: 181 bytes --]


?

The root cause was that the thing would expect a “gz” extension when it
couldn’t find an extension.

If that works for you, feel free to push!

Thanks,
Ludo’.

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

* Re: [PATCH 07/12] gnu: Add rust bootstrap binaries.
  2016-12-11 17:25 ` [PATCH 07/12] gnu: Add rust bootstrap binaries David Craven
@ 2016-12-13 22:44   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:44 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/packages/rust.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add rust.scm.

There are a couple of comments from
<https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00158.html>
that remain valid, I think.  Could you double-check?

> +(define (system->rust-platform system)
> +  (cond
> +   ((string-prefix? "x86_64" system) "x86_64-unknown-linux-gnu")
> +   ((string-prefix? "i686" system) "i686-unknown-linux-gnu")
> +   (else #f)))

I think you can remove this procedure and use ‘nix-system->gnu-triplet’
instead.

> +    (inputs
> +     ;; FIXME: Use system gcc:lib. Does gcc "lib" need to be
> +     ;; added to %final-inputs?
> +     `(("gcc:lib" ,gcc "lib")

Use (canonical-package gcc).

> +(define-public rust-bootstrap
> +  (package
> +    (name "rust-bootstrap")
> +    (version %rust-bootstrap-binaries-version)
> +    (source #f)
> +    (build-system trivial-build-system)
> +    (propagated-inputs
> +     ;; XXX: guix size shows a size of zero. Are propagated inputs not
> +     ;; counted?
> +     `(("rustc-bootstrap" ,rustc-bootstrap)
> +       ("cargo-bootstrap" ,cargo-bootstrap)))
> +    (arguments
> +     `(#:builder
> +       (begin (mkdir (assoc-ref %outputs "out")))))
> +    (home-page "https://www.rust-lang.org")
> +    (synopsis "Rust bootstrap")

“Rust bootstrapping meta-package”

OK with appropriate changes, thanks!

Ludo’.

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

* Re: [PATCH 08/12] gnu: Add rustc.
  2016-12-11 17:25 ` [PATCH 08/12] gnu: Add rustc David Craven
@ 2016-12-13 22:47   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:47 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/packages/rust.scm (rustc): New variable.
>
> Co-authored-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>

[...]

> +    (synopsis "Compiler for the Rust progamming language")
> +    (description "Rust is a systems programming language that runs blazingly
> +fast, prevents segfaults, and guarantees thread safety.")

Buzzwords!  :-)  “Rust … language with an efficient compiler, and it
provides memory safety and thread safety guarantees.”

> +    (license (list license:asl2.0 license:expat))))

Please add a comment explaining whether this is “at the user’s choice”
or rather a combination of licenses.

OK with these changes.

Thanks,
Ludo’.

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

* Re: [PATCH 09/12] gnu: Add rust-libc.
  2016-12-11 17:25 ` [PATCH 09/12] gnu: Add rust-libc David Craven
@ 2016-12-13 22:48   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:48 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/packages/rust.scm (rust-libc): New variable.

[...]

> +    (license (list license:expat license:asl2.0))))

Please clarify what this means.

Otherwise LGTM, thanks!

Ludo’.

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

* Re: [PATCH 10/12] RECURSIVE IMPORTER wip
  2016-12-11 17:25 ` [PATCH 10/12] RECURSIVE IMPORTER wip David Craven
@ 2016-12-13 22:49   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:49 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

I’m punting on this one because this has to be synchronized with other
people doing importer stuff.

Ludo’.

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

* Re: [PATCH 11/12] gnu: Add rust-rand.
  2016-12-11 17:25 ` [PATCH 11/12] gnu: Add rust-rand David Craven
@ 2016-12-13 22:50   ` Ludovic Courtès
  2017-01-03  0:52   ` Danny Milosavljevic
  1 sibling, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:50 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/packages/rust.scm (rust-rand): New variable.

[...]

> +    (synopsis "Random number generators")
> +    (description "Random number generators and other randomness functionality.")

Full sentence please!

> +    (license (list license:expat license:asl2.0))))

Same as before.

OK with these changes, thanks!

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

* Re: [PATCH 06/12] gnu: llvm: Enable install utils.
  2016-12-11 17:25 ` [PATCH 06/12] gnu: llvm: Enable install utils David Craven
@ 2016-12-13 22:50   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:50 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/packages/llvm.scm (llvm)[arguments]: Add -DLLVM_INStALL_UTILS=ON
>   to configure-flags.
> ---
>  gnu/packages/llvm.scm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
> index 96679bf97..c425108c9 100644
> --- a/gnu/packages/llvm.scm
> +++ b/gnu/packages/llvm.scm
> @@ -60,7 +60,8 @@
>       `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
>                             "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
>                             "-DBUILD_SHARED_LIBS:BOOL=TRUE"
> -                           "-DLLVM_ENABLE_FFI:BOOL=TRUE")
> +                           "-DLLVM_ENABLE_FFI:BOOL=TRUE"
> +                           "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.

If the closure size increase is “reasonable”, go ahead!

Thanks,
Ludo’.

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

* Re: [PATCH 12/12] gnu: Add cargo.
  2016-12-11 17:25 ` [PATCH 12/12] gnu: Add cargo David Craven
@ 2016-12-13 22:51   ` Ludovic Courtès
  0 siblings, 0 replies; 31+ messages in thread
From: Ludovic Courtès @ 2016-12-13 22:51 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * gnu/packages/rust.scm (cargo): New variable.

LGTM, thanks!

Ludo’.

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

* Re: [PATCH 02/12] build-system: Add cargo build system.
  2016-12-11 17:25 ` [PATCH 02/12] build-system: Add cargo build system David Craven
  2016-12-13 17:26   ` Ludovic Courtès
@ 2016-12-30 11:08   ` Danny Milosavljevic
  2017-01-01 14:42     ` David Craven
  1 sibling, 1 reply; 31+ messages in thread
From: Danny Milosavljevic @ 2016-12-30 11:08 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

Hi,

when I use git-download, the files it checked out will have r-- permissions and thus cargo-build-system can't patch Cargo.toml .

To reproduce, try:

(define-public rust-c-vec
 (package
  (name "rust-c-vec")
  (version "1.1.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
          "0crdx88z8cfmc3j7d71max46acjdz2fgi9izifdw2gh13nzg83rk"))))
  (build-system cargo-build-system)
  (native-inputs `(("rust-libc" ,rust-libc)))
  (home-page "FIXME") ; FIXME fixed manually. It said ()
  (synopsis "Structures to wrap C arrays")
  (description "Structures to wrap C arrays")
  (license (list license:asl2.0 license:expat))))

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

* Re: [PATCH 02/12] build-system: Add cargo build system.
  2016-12-30 11:08   ` Danny Milosavljevic
@ 2017-01-01 14:42     ` David Craven
  0 siblings, 0 replies; 31+ messages in thread
From: David Craven @ 2017-01-01 14:42 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Yes this is a bug. Before modifying Cargo.toml we should chmod +w.
Thank you for reporting it. The home-page issue in the importer also
needs fixing.

I expressed being against deduplicating the inputs because I think
that that is subject to change in the future.

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

* Re: [PATCH 11/12] gnu: Add rust-rand.
  2016-12-11 17:25 ` [PATCH 11/12] gnu: Add rust-rand David Craven
  2016-12-13 22:50   ` Ludovic Courtès
@ 2017-01-03  0:52   ` Danny Milosavljevic
  1 sibling, 0 replies; 31+ messages in thread
From: Danny Milosavljevic @ 2017-01-03  0:52 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

This is missing a native-input rust-log for the tests.

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

end of thread, other threads:[~2017-01-03  0:53 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-11 17:25 [PATCH 00/12] Rust build system v2 David Craven
2016-12-11 17:25 ` [PATCH 01/12] upstream: Use a the first url from urls when find2 returns #f David Craven
2016-12-13 17:25   ` Ludovic Courtès
2016-12-13 20:07     ` David Craven
2016-12-13 22:22       ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 02/12] build-system: Add cargo build system David Craven
2016-12-13 17:26   ` Ludovic Courtès
2016-12-30 11:08   ` Danny Milosavljevic
2017-01-01 14:42     ` David Craven
2016-12-11 17:25 ` [PATCH 03/12] import: utils: Add some utilities David Craven
2016-12-13 17:29   ` Ludovic Courtès
2016-12-13 18:09     ` David Craven
2016-12-11 17:25 ` [PATCH 04/12] import: Add importer for rust crates David Craven
2016-12-13 17:30   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 05/12] import: Add updater " David Craven
2016-12-13 17:30   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 06/12] gnu: llvm: Enable install utils David Craven
2016-12-13 22:50   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 07/12] gnu: Add rust bootstrap binaries David Craven
2016-12-13 22:44   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 08/12] gnu: Add rustc David Craven
2016-12-13 22:47   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 09/12] gnu: Add rust-libc David Craven
2016-12-13 22:48   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 10/12] RECURSIVE IMPORTER wip David Craven
2016-12-13 22:49   ` Ludovic Courtès
2016-12-11 17:25 ` [PATCH 11/12] gnu: Add rust-rand David Craven
2016-12-13 22:50   ` Ludovic Courtès
2017-01-03  0:52   ` Danny Milosavljevic
2016-12-11 17:25 ` [PATCH 12/12] gnu: Add cargo David Craven
2016-12-13 22:51   ` Ludovic Courtès

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.