diff mbox

[12/12] gnu: Add rust helper functions.

Message ID 20160922131903.1606-12-david@craven.ch
State New
Headers show

Commit Message

David Craven Sept. 22, 2016, 1:19 p.m. UTC
* gnu/packages/rust.scm (crate-uri, system->rust-platform): New
  variables.
---
 gnu/packages/rust.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Ludovic Courtès Sept. 26, 2016, 10:29 a.m. UTC | #1
David Craven <david@craven.ch> skribis:

> * gnu/packages/rust.scm (crate-uri, system->rust-platform): New
>   variables.

Oh, now I see.  :-)  This patch should come earlier, but as I wrote
before, I’d rather have those procedures in the build system or
importer, to avoid loading all of (gnu packages …) just for them.

Thanks a lot for this big series!

Ludo’.
diff mbox

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 33c1d5c..ebb9727 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -26,7 +26,18 @@ 
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
   #:use-module (guix packages)
-  #:use-module ((guix licenses) #:prefix license:))
+  #:use-module ((guix licenses) #:prefix license:)
+  #:export (crate-uri))
+
+(define (crate-uri name version)
+  "Return a URI string for the crate package hosted at crates.io corresponding
+to NAME and VERSION."
+  (string-append "https://crates.io/api/v1/crates/" name "/" version "/download"))
+
+(define (system->rust-platform system)
+  (cond
+   ((string-prefix? "x86_64" system) "x86_64-unknown-linux-gnu")
+   ((string-prefix? "i686" system) "i686-unknown-linux-gnu")))
 
 (define rust-bootstrap-x86_64-1.12.0
   (origin