1{ stdenv, fetchFromGitHub, rustPlatform, darwin }:
2
3rustPlatform.buildRustPackage rec {
4 name = "rustfmt-${version}";
5 version = "1.0.1";
6
7 src = fetchFromGitHub {
8 owner = "rust-lang";
9 repo = "rustfmt";
10 rev = "${version}";
11 sha256 = "1l18ycbq3125sq8v3wgma630wd6kclarlf8f51cmi9blk322jg9p";
12 };
13
14 cargoSha256 = "1557783icdzlwn02c5zl4362yl85r5zj4nkjv80p6896yli9hk9h";
15
16 buildInputs = stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
17
18 # As of 1.0.0 and rustc 1.30 rustfmt requires a nightly compiler
19 RUSTC_BOOTSTRAP = 1;
20
21 # we run tests in debug mode so tests look for a debug build of
22 # rustfmt. Anyway this adds nearly no compilation time.
23 preCheck = ''
24 cargo build
25 '';
26
27 meta = with stdenv.lib; {
28 description = "A tool for formatting Rust code according to style guidelines";
29 homepage = https://github.com/rust-lang-nursery/rustfmt;
30 license = with licenses; [ mit asl20 ];
31 maintainers = [ maintainers.globin ];
32 platforms = platforms.all;
33 };
34}