aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Kraai <kraai@ftbfs.org>2020-12-02 05:18:35 -0800
committerLeo Famulari <leo@famulari.name>2020-12-13 17:56:44 -0500
commit48926b588528c5a2b591e1e97a5757eb78d3cac1 (patch)
treeb61a47ece410dbc33364f27f952b54dc30096719
parenta73302ec91855fa1913a2702daee25f8b9cf487b (diff)
downloadguix-48926b588528c5a2b591e1e97a5757eb78d3cac1.tar
guix-48926b588528c5a2b591e1e97a5757eb78d3cac1.tar.gz
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.
-rw-r--r--gnu/packages/rust.scm67
1 files 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)