diff mbox series

[bug#42295] gnu: rust-1.44: Add rustfmt output.

Message ID 977d1171-d1af-5705-3852-1bee82047445@ftbfs.org
State Accepted
Headers show
Series [bug#42295] gnu: rust-1.44: Add rustfmt output. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Matthew James Kraai Dec. 2, 2020, 1:29 p.m. UTC
Hi John,

On 11/26/20 8:51 AM, John Soo wrote:
> Matthew Kraai <kraai@ftbfs.org> writes:
>> According to https://github.com/rust-lang/rustfmt, rustfmt was made a
>> component in 1.24.0.  Would it be better to add this support to the
>> rust-1.24 package instead?  I've attached the patch I'm currently testing.
> Keep it on rust@1.44. Even though guix refresh --list-dependent will
> report not many dependents, changing a current rust version would
> trigger many rebuilds. There would be enough rebuilds to require it to
> be applied to staging.
>
> I've also attached a work in progress patch to add rls as an output,
> too.  I would love if all the "extended" tools can be included. Some
> tools like clippy and the rust-src component would be very helpful.
>
> One other thing:
>
>> +      (outputs '("out" "doc" "cargo" "rustfmt"))
> should probably be: (cons "rustfmt" (package-outputs base-rust))
>
> to be more resistant to changes to older packages.
Here is an updated patch.  I modified the rust-1.46 package, used your 
suggestion to add rustfmt to the list of outputs, did not modify the 
mkdir-prefix-paths phase (which doesn't seem to be necessary), and 
updated the delete-install-logs phase.

Comments

Efraim Flashner Jan. 28, 2021, 6:32 p.m. UTC | #1
This is applied on staging so closing the bug
diff mbox series

Patch

From 600cc3f1f4a38847aea48edb0e1e7e365bd00d8c Mon Sep 17 00:00:00 2001
From: Matthew Kraai <kraai@ftbfs.org>
Date: Wed, 2 Dec 2020 05:18:35 -0800
Subject: [PATCH] gnu: rust-1.46: Add rustfmt output

* gnu/packages/rust.scm (rust-1.46): Add a rustfmt output.
---
 gnu/packages/rust.scm | 67 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 35a96b5754..749d1f031f 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -10,6 +10,7 @@ 
 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020 Matthew Kraai <kraai@ftbfs.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1315,8 +1316,70 @@  move around."
                  #t)))))))))
 
 (define-public rust-1.46
-  (rust-bootstrapped-package rust-1.45 "1.46.0"
-    "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))
+  (let ((base-rust
+         (rust-bootstrapped-package rust-1.45 "1.46.0"
+           "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid")))
+    (package
+      (inherit base-rust)
+      (outputs (cons "rustfmt" (package-outputs base-rust)))
+      (arguments
+       (substitute-keyword-arguments (package-arguments base-rust)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (replace 'build
+               (lambda* _
+                 (invoke "./x.py" "build")
+                 (invoke "./x.py" "build" "src/tools/cargo")
+                 (invoke "./x.py" "build" "src/tools/rustfmt")))
+             (replace 'check
+               (lambda* _
+                 ;; Test rustfmt.
+                 (let ((parallel-job-spec
+                        (string-append "-j" (number->string
+                                             (min 4
+                                                  (parallel-job-count))))))
+                   (invoke "./x.py" parallel-job-spec "test" "-vv")
+                   (invoke "./x.py" parallel-job-spec "test"
+                           "src/tools/cargo")
+                   (invoke "./x.py" parallel-job-spec "test"
+                           "src/tools/rustfmt"))))
+             (replace 'install
+               (lambda* (#:key outputs #:allow-other-keys)
+                 (invoke "./x.py" "install")
+                 (substitute* "config.toml"
+                   ;; replace prefix to specific output
+                   (("prefix = \"[^\"]*\"")
+                    (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
+                 (invoke "./x.py" "install" "cargo")
+                 (substitute* "config.toml"
+                   ;; replace prefix to specific output
+                   (("prefix = \"[^\"]*\"")
+                    (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
+                 (invoke "./x.py" "install" "rustfmt")))
+             (replace 'delete-install-logs
+               (lambda* (#:key outputs #:allow-other-keys)
+                 (define (delete-manifest-file out-path file)
+                   (delete-file (string-append out-path "/lib/rustlib/" file)))
+
+                 (let ((out (assoc-ref outputs "out"))
+                       (cargo-out (assoc-ref outputs "cargo"))
+                       (rustfmt-out (assoc-ref outputs "rustfmt")))
+                   (for-each
+                     (lambda (file) (delete-manifest-file out file))
+                     '("install.log"
+                       "manifest-rust-docs"
+                       ,(string-append "manifest-rust-std-"
+                                       (nix-system->gnu-triplet-for-rust))
+                       "manifest-rustc"))
+                   (for-each
+                     (lambda (file) (delete-manifest-file cargo-out file))
+                     '("install.log"
+                       "manifest-cargo"))
+                   (for-each
+                     (lambda (file) (delete-manifest-file rustfmt-out file))
+                     '("install.log"
+                       "manifest-rustfmt-preview"))
+                   #t))))))))))
 
 ;; TODO(staging): Bump this variable to the latest packaged rust.
 (define-public rust rust-1.45)
-- 
2.29.2