Skip to content

Commit

Permalink
Add make-cargo-build-system
Browse files Browse the repository at this point in the history
  • Loading branch information
declantsien committed Jul 3, 2024
1 parent 34e702c commit 9e0d279
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions guix/rustup/build/toolchain.scm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#:use-module (web uri)
#:use-module (guix utils)
#:use-module (guix records)
#:use-module (guix build-system)
#:use-module (guix build-system cargo)
#:use-module (guix i18n)
#:use-module ((guix build utils) #:select (find-files symbolic-link?))
#:use-module ((gnu home services utils) #:select (list->human-readable-list))
Expand Down Expand Up @@ -51,6 +53,7 @@
#:use-module (gnu packages)
#:use-module (gnu packages gcc)
#:export (rustup
make-cargo-build-system
toolchain->new
toolchain->from-file
toolchain->source
Expand Down Expand Up @@ -448,6 +451,34 @@ safety and thread safety guarantees.")
(info (G_ "Loading Rust toolchain from '~a'...~%") file)
(parse-rust-toolchain-file file))))))

(define* (make-cargo-build-system . toolchain-spec)
"Return a variant of Cargo BS, a build system, that uses TOOLCHAIN spec
instead of the default rust toolchain. TOOLCHAIN-SPEC are directly passed
to procedure rustup"
(define toolchain (apply rustup toolchain-spec))

(define lower
(build-system-lower cargo-build-system))

(define toolchain-packages
;; These are the GNU toolchain packages pulled in by CARGO-BUILD-SYSTEM and
;; all the build systems that inherit from it.
'("rustc" "cargo" "rust-toolchain"))

(define (lower* . args)
(let ((lowered (apply lower args)))
(bag
(inherit lowered)
(build-inputs
(append (fold alist-delete
(bag-build-inputs lowered)
toolchain-packages)
(list `("rust-toolchain" ,toolchain)))))))

(build-system
(inherit cargo-build-system)
(lower lower*)))

(define* (select-latest-nightly-with file)
;; Select the latest nightly toolchain which have specific components or profile available.This helps nightly users in case of latest nightly may not contains all components they want.
;; `select-latest-nightly-with (toolchain: toolchain.default)` selects the latest nightly toolchain with all `default` components (rustc, cargo, rustfmt, ...) available.
Expand Down

0 comments on commit 9e0d279

Please sign in to comment.