From 48926b588528c5a2b591e1e97a5757eb78d3cac1 Mon Sep 17 00:00:00 2001 From: Matthew Kraai Date: Wed, 2 Dec 2020 05:18:35 -0800 Subject: gnu: rust-1.46: Add rustfmt output * gnu/packages/rust.scm (rust-1.46)[outputs]: Add a rustfmt output. [arguments]: Adjust to the new 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 ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2020 Pierre Langlois +;;; Copyright © 2020 Matthew Kraai ;;; ;;; 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) -- cgit v1.2.3