guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: gnu: rust: Add 1.39


From: guix-commits
Subject: 02/02: gnu: rust: Add 1.39
Date: Fri, 27 Mar 2020 09:30:10 -0400 (EDT)

niedzejkob pushed a commit to branch master
in repository guix.

commit 9483782a617c66b8e066ac7f1898e41f99eb8456
Author: Jakub Kądziołka <address@hidden>
AuthorDate: Sun Mar 8 23:32:35 2020 +0100

    gnu: rust: Add 1.39
    
    * gnu/packages/rust.scm (rust-1.39): New variable.
      (%cargo-reference-hash): Add a comment explaining the role of the
      variable.
---
 gnu/packages/rust.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index e010684..11522b9 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -55,6 +55,32 @@
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-26))
 
+;; This is the hash for the empty file, and the reason it's relevant is not
+;; the most obvious.
+;;
+;; The root of the problem is that Cargo keeps track of a file called
+;; Cargo.lock, that contains the hash of the tarball source of each dependency.
+;;
+;; However, tarball sources aren't handled well by Guix because of the need to
+;; patch shebangs in any helper scripts. This is why we use Cargo's vendoring
+;; capabilities, where instead of the tarball, a directory is provided in its
+;; place. (In the case of rustc, the source code already ships with vendored
+;; dependencies, but crates built with cargo-build-system undergo vendoring
+;; during the build.)
+;;
+;; To preserve the advantages of checksumming, vendored dependencies contain
+;; a file called .cargo-checksum.json, which contains the hash of the tarball,
+;; as well as the list of files in it, with the hash of each file.
+;;
+;; The patch-cargo-checksums phase of cargo-build-system runs after
+;; any Guix-specific patches to the vendored dependencies and regenerates the
+;; .cargo-checksum.json files, but it's hard to know the tarball checksum that
+;; should be written to the file - and taking care of any unhandled edge case
+;; would require rebuilding everything that depends on rust. This is why we 
lie,
+;; and say that the tarball has the hash of an empty file. It's not a problem
+;; because cargo-build-system removes the Cargo.lock file. We can't do that
+;; for rustc because of a quirk of its build system, so we modify the lock file
+;; to substitute the hash.
 (define %cargo-reference-hash
   "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
 
@@ -1130,4 +1156,24 @@ move around."
                    (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
                  #t)))))))))
 
+(define-public rust-1.39
+  (let ((base-rust
+         (rust-bootstrapped-package rust-1.38 "1.39.0"
+           "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
+    (package
+      (inherit base-rust)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base-rust)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (replace 'patch-cargo-checksums
+               ;; The Cargo.lock format changed.
+               (lambda* _
+                 (use-modules (guix build cargo-utils))
+                 (substitute* "Cargo.lock"
+                   (("(checksum = )\".*\"" all name)
+                    (string-append name "\"" ,%cargo-reference-hash "\"")))
+                 (generate-all-checksums "vendor")
+                 #t)))))))))
+
 (define-public rust rust-1.37)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]