unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthew Kraai <kraai@ftbfs.org>
To: John Soo <jsoo1@asu.edu>
Cc: 42295@debbugs.gnu.org
Subject: [bug#42295] [PATCH] gnu: rust-1.44: Add rustfmt output.
Date: Wed, 2 Dec 2020 05:29:25 -0800	[thread overview]
Message-ID: <977d1171-d1af-5705-3852-1bee82047445@ftbfs.org> (raw)
In-Reply-To: <871rggt62e.fsf@asu.edu>

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

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.

-- 
Matthew Kraai


[-- Attachment #2: 0001-gnu-rust-1.46-Add-rustfmt-output.patch --]
[-- Type: text/x-patch, Size: 4345 bytes --]

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


  reply	other threads:[~2020-12-02 13:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 12:32 [bug#42295] [PATCH] gnu: rust-1.44: Add rustfmt output Matthew Kraai
2020-11-25 14:46 ` John Soo
2020-11-26 13:25   ` Matthew Kraai
2020-11-26 16:51     ` John Soo
2020-12-02 13:29       ` Matthew Kraai [this message]
2021-01-28 18:32         ` bug#42295: " Efraim Flashner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=977d1171-d1af-5705-3852-1bee82047445@ftbfs.org \
    --to=kraai@ftbfs.org \
    --cc=42295@debbugs.gnu.org \
    --cc=jsoo1@asu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).