diff --git a/pkgs/development/compilers/rust/rustfmt.nix b/pkgs/development/compilers/rust/rustfmt.nix index 42c71513151a..569ec815e36a 100644 --- a/pkgs/development/compilers/rust/rustfmt.nix +++ b/pkgs/development/compilers/rust/rustfmt.nix @@ -1,6 +1,14 @@ -{ lib, stdenv, rustPlatform, rustc, Security, asNightly ? false }: +{ lib +, stdenv +, cargo +, makeWrapper +, rustPlatform +, rustc +, Security +, asNightly ? false +}: -rustPlatform.buildRustPackage rec { +rustPlatform.buildRustPackage { pname = "rustfmt" + lib.optionalString asNightly "-nightly"; inherit (rustc) version src; @@ -11,6 +19,10 @@ rustPlatform.buildRustPackage rec { # changes hash of vendor directory otherwise dontUpdateAutotoolsGnuConfigScripts = true; + nativeBuildInputs = [ + makeWrapper + ]; + buildInputs = [ rustc.llvm ] ++ lib.optional stdenv.hostPlatform.isDarwin Security; @@ -34,6 +46,11 @@ rustPlatform.buildRustPackage rec { CFG_RELEASE = rustc.version; CFG_RELEASE_CHANNEL = if asNightly then "nightly" else "stable"; + postInstall = '' + wrapProgram $out/bin/cargo-fmt \ + --suffix PATH : ${lib.makeBinPath [ cargo ]} + ''; + meta = with lib; { description = "Tool for formatting Rust code according to style guidelines"; homepage = "https://github.com/rust-lang-nursery/rustfmt";