diff mbox series

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

Message ID 871rggt62e.fsf@asu.edu
State Accepted
Headers show
Series [bug#42295] gnu: rust-1.44: Add rustfmt output. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

John Soo Nov. 26, 2020, 4:51 p.m. UTC
Hi Matthew,

Matthew Kraai <kraai@ftbfs.org> writes:

>> Perhaps we should make anything that can be installed as a rustup
>> component an output (provided the source is in the rust tree). I think
>> rls can be added immediately in the same fashion.
> Is rls deprecated in favor of rust-analyzer?

Yes but I think it should be included until it is not supported at all
anymore.

> 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.

Best regards,

John
diff mbox series

Patch

From 7e26e4c61a609e93199acdff608272e3cbc38c76 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Wed, 25 Nov 2020 06:30:02 -0800
Subject: [PATCH] gnu: Add rls as an output of rust@1.44.

* gnu/packages/rust.scm (rust-1.44):[arguments] Build rls, [outputs] add rls.
---
 gnu/packages/rust.scm | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 23837ee5bf..ae23d98b98 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1284,16 +1284,24 @@  move around."
            "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky")))
     (package
       (inherit base-rust)
-      (outputs (cons "rustfmt" (package-outputs base-rust)))
+      (outputs (append '("rustfmt" "rls") (package-outputs base-rust)))
       (arguments
        (substitute-keyword-arguments (package-arguments base-rust)
          ((#:phases phases)
           `(modify-phases ,phases
              (replace 'build
                (lambda* _
+                 (substitute* "config.toml"
+                   ;; replace prefix to specific output
+                   (("\\[build\\]" all)
+                    (string-append all "
+extended = true
+tools = [\"cargo\", \"rls\", \"clippy\", \"rustfmt\", \"analysis\", \"src\"]
+")))
                  (invoke "./x.py" "build")
                  (invoke "./x.py" "build" "src/tools/cargo")
-                 (invoke "./x.py" "build" "src/tools/rustfmt")))
+                 (invoke "./x.py" "build" "src/tools/rustfmt")
+                 (invoke "./x.py" "build" "src/tools/rls")))
              (replace 'check
                (lambda* _
                  ;; Enable parallel execution.
@@ -1305,7 +1313,12 @@  move around."
                    (invoke "./x.py" parallel-job-spec "test"
                            "src/tools/cargo")
                    (invoke "./x.py" parallel-job-spec "test"
-                           "src/tools/rustfmt"))))
+                           "src/tools/rustfmt")
+                   (substitute* "src/tools/rls/tests/client.rs"
+                     (("fn client_dependency_typo_and_fix" all)
+                      (string-append "#[ignore]\n" all)))
+                   (invoke "./x.py" parallel-job-spec "test"
+                           "src/tools/rls"))))
              (replace 'mkdir-prefix-paths
                (lambda* (#:key outputs #:allow-other-keys)
                  ;; As result of https://github.com/rust-lang/rust/issues/36989
@@ -1313,6 +1326,7 @@  move around."
                  (mkdir-p (assoc-ref outputs "out"))
                  (mkdir-p (assoc-ref outputs "cargo"))
                  (mkdir-p (assoc-ref outputs "rustfmt"))
+                 (mkdir-p (assoc-ref outputs "rls"))
                  #t))
              (replace 'install
                (lambda* (#:key outputs #:allow-other-keys)
@@ -1326,7 +1340,18 @@  move around."
                    ;; replace prefix to specific output
                    (("prefix = \"[^\"]*\"")
                     (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
-                 (invoke "./x.py" "install" "rustfmt"))))))))))
+                 (invoke "./x.py" "install" "rustfmt")
+                 (substitute* "config.toml"
+                   ;; replace prefix to specific output
+                   (("prefix = \"[^\"]*\"")
+                    (string-append "prefix = \"" (assoc-ref outputs "rls") "\"")))
+                 (invoke "./x.py" "install" "rls")))
+             (replace 'validate-runpath
+               (lambda* (#:key outputs #:allow-other-keys #:rest rest)
+                 (apply (assoc-ref %standard-phases 'validate-runpath)
+                        ;; rls has references to "out"
+                        #:outputs (alist-delete "rls" outputs)
+                        rest))))))))))
 
 (define-public rust-1.45
   (let ((base-rust
-- 
2.29.2