about summary refs log tree commit diff
path: root/pkgs/aszlig/rustfmt/default.nix
blob: 9ec78bf979127e844717ff2d7ff05eadb741bc62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ rustfmt, runCommand, remarshal }:

let
  defaultConfig = {
    format_code_in_doc_comments = true;
    format_macro_matchers = true;
    format_strings = true;
    group_imports = "StdExternalCrate";
    match_block_trailing_comma = true;
    max_width = 79;
    newline_style = "Unix";
    normalize_doc_attributes = true;
    overflow_delimited_expr = true;
    reorder_impl_items = true;
    unstable_features = true;
    use_field_init_shorthand = true;
    use_try_shorthand = true;
    wrap_comments = true;
  };

in (rustfmt.override { asNightly = true; }).overrideAttrs (drv: {
  patches = (drv.patches or []) ++ [ ./config.patch ];
  DEFAULT_CONFIG_FILE = runCommand "rustfmt.conf" {
    nativeBuildInputs = [ remarshal ];
    value = builtins.toJSON defaultConfig;
    passAsFile = [ "value" ];
  } ''
    json2toml "$valuePath" "$out"
  '';
})