diff --git a/pkgs/build-support/rust/build-rust-crate/build-crate.nix b/pkgs/build-support/rust/build-rust-crate/build-crate.nix index 0978f7e1756f..2999c3d4c1d9 100644 --- a/pkgs/build-support/rust/build-rust-crate/build-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/build-crate.nix @@ -11,7 +11,7 @@ rustcOpts = lib.lists.foldl' (opts: opt: opts + " " + opt) (if release then "-C opt-level=3" else "-C debuginfo=2") - (["-C codegen-units=1"] ++ extraRustcOpts); + (["-C codegen-units=$NIX_BUILD_CORES"] ++ extraRustcOpts); rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}"; # Some platforms have different names for rustc. diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index b184d363d554..165b3414c6a3 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -22,7 +22,7 @@ let version_ = lib.splitString "-" crateVersion; version = lib.splitString "." (lib.head version_); rustcOpts = lib.lists.foldl' (opts: opt: opts + " " + opt) (if release then "-C opt-level=3" else "-C debuginfo=2") - (["-C codegen-units=1"] ++ extraRustcOpts); + (["-C codegen-units=$NIX_BUILD_CORES"] ++ extraRustcOpts); buildDeps = makeDeps buildDependencies; authors = lib.concatStringsSep ":" crateAuthors; optLevel = if release then 3 else 0;