diff mbox series

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

Message ID 20200709123256.7690-1-kraai@ftbfs.org
State Accepted
Headers show
Series [bug#42295] gnu: rust-1.44: Add rustfmt output. | expand

Checks

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

Commit Message

Matthew James Kraai July 9, 2020, 12:32 p.m. UTC
* gnu/packages/rust.scm (rust-1.44): Add a rustfmt output.
---
 gnu/packages/rust.scm | 50 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

Comments

John Soo Nov. 25, 2020, 2:46 p.m. UTC | #1
Hi Matthew,

Thanks! I had packaged rustfmt-nightly but this is much better.

Matthew Kraai <kraai@ftbfs.org> writes:

> +             (replace 'check
> +               (lambda* _
> +                 ;; Enable parallel execution.
> +                 (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"))))

Nice!

> +      (outputs '("out" "doc" "cargo" "rustfmt"))

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.

Do you want to add a copyright line?

Otherwise, this looks good to me.

Best regards,

John
diff mbox series

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 6fc0fd4f52..52aef9478b 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1277,8 +1277,54 @@  move around."
     "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
 
 (define-public rust-1.44
-  (rust-bootstrapped-package rust-1.43 "1.44.1"
-    "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
+  (let ((base-rust
+         (rust-bootstrapped-package rust-1.43 "1.44.1"
+           "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky")))
+    (package
+      (inherit base-rust)
+      (outputs '("out" "doc" "cargo" "rustfmt"))
+      (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* _
+                 ;; Enable parallel execution.
+                 (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 'mkdir-prefix-paths
+               (lambda* (#:key outputs #:allow-other-keys)
+                 ;; As result of https://github.com/rust-lang/rust/issues/36989
+                 ;; `prefix' directory should exist before `install' call
+                 (mkdir-p (assoc-ref outputs "out"))
+                 (mkdir-p (assoc-ref outputs "cargo"))
+                 (mkdir-p (assoc-ref outputs "rustfmt"))
+                 #t))
+             (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"))))))))))
 
 ;; NOTE: An update to LLVM 10 is coming in 1.45, make sure not to miss it.