rustfmt: allow building as nightly

This is used by bindgen, and may be useful for other projects
as well, as rustfmt disables many features when built as stable.
This commit is contained in:
K900 2022-04-06 11:03:37 +03:00
parent 6eb00a41a0
commit ddef8a68cb
3 changed files with 7 additions and 3 deletions

View file

@ -77,6 +77,7 @@ in
pkgsBuildTarget = pkgsBuildTarget // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; };
});
rustfmt = self.callPackage ./rustfmt.nix { inherit Security; };
rustfmt-nightly = self.callPackage ./rustfmt.nix { inherit Security; asNightly = true; };
cargo = self.callPackage ./cargo.nix {
# Use boot package set to break cycle
rustPlatform = bootRustPlatform;

View file

@ -1,7 +1,7 @@
{ lib, stdenv, rustPlatform, Security }:
{ lib, stdenv, rustPlatform, Security, asNightly ? false }:
rustPlatform.buildRustPackage rec {
pname = "rustfmt";
pname = "rustfmt" + lib.optionalString asNightly "-nightly";
inherit (rustPlatform.rust.rustc) version src;
# the rust source tarball already has all the dependencies vendored, no need to fetch them again
@ -19,7 +19,7 @@ rustPlatform.buildRustPackage rec {
# As of rustc 1.45.0, these env vars are required to build rustfmt (due to
# https://github.com/rust-lang/rust/pull/72001)
CFG_RELEASE = rustPlatform.rust.rustc.version;
CFG_RELEASE_CHANNEL = "stable";
CFG_RELEASE_CHANNEL = if asNightly then "nightly" else "stable";
# FIXME: seems fixed upstream, remove after the next update
patches = [ ./rustfmt-fix-self-tests.patch ];

View file

@ -13471,7 +13471,10 @@ with pkgs;
rhack = callPackage ../development/tools/rust/rhack { };
inherit (rustPackages) rls;
roogle = callPackage ../development/tools/rust/roogle { };
rustfmt = rustPackages.rustfmt;
rustfmt-nightly = rustPackages.rustfmt-nightly;
rustracer = callPackage ../development/tools/rust/racer {
inherit (darwin.apple_sdk.frameworks) Security;
};