summary refs log tree commit diff
diff options
context:
space:
mode:
authorK900 <me@0upti.me>2022-04-06 11:03:37 +0300
committerK900 <me@0upti.me>2022-04-06 13:03:23 +0300
commitddef8a68cb5e49323dbb293fd34b079cfa1f8b7a (patch)
treed11c5016f472463167a2b2c0638627016c0601a9
parent6eb00a41a0850e10e6a12021332a147dd97578a5 (diff)
downloadnixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.tar
nixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.tar.gz
nixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.tar.bz2
nixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.tar.lz
nixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.tar.xz
nixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.tar.zst
nixpkgs-ddef8a68cb5e49323dbb293fd34b079cfa1f8b7a.zip
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.
-rw-r--r--pkgs/development/compilers/rust/default.nix1
-rw-r--r--pkgs/development/compilers/rust/rustfmt.nix6
-rw-r--r--pkgs/top-level/all-packages.nix3
3 files changed, 7 insertions, 3 deletions
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix
index 6dfc8a49063..82579db0e47 100644
--- a/pkgs/development/compilers/rust/default.nix
+++ b/pkgs/development/compilers/rust/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/rust/rustfmt.nix b/pkgs/development/compilers/rust/rustfmt.nix
index 9922d60ef70..5916b6c07fb 100644
--- a/pkgs/development/compilers/rust/rustfmt.nix
+++ b/pkgs/development/compilers/rust/rustfmt.nix
@@ -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 ];
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 227cdccaec1..851c2618213 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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;
   };