diff options
Diffstat (limited to 'pkgs/aszlig/rustfmt')
-rw-r--r-- | pkgs/aszlig/rustfmt/config.patch | 13 | ||||
-rw-r--r-- | pkgs/aszlig/rustfmt/default.nix | 31 |
2 files changed, 44 insertions, 0 deletions
diff --git a/pkgs/aszlig/rustfmt/config.patch b/pkgs/aszlig/rustfmt/config.patch new file mode 100644 index 00000000..0a49a585 --- /dev/null +++ b/pkgs/aszlig/rustfmt/config.patch @@ -0,0 +1,13 @@ +diff --git a/src/config/mod.rs b/src/config/mod.rs +index cd90e090..a6db6da1 100644 +--- a/src/config/mod.rs ++++ b/src/config/mod.rs +@@ -282,7 +282,7 @@ impl Config { + } + } + +- Ok(None) ++ Ok(Some(env!("DEFAULT_CONFIG_FILE").into())) + } + + match resolve_project_file(dir)? { diff --git a/pkgs/aszlig/rustfmt/default.nix b/pkgs/aszlig/rustfmt/default.nix new file mode 100644 index 00000000..cde4d010 --- /dev/null +++ b/pkgs/aszlig/rustfmt/default.nix @@ -0,0 +1,31 @@ +{ 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.overrideAttrs (drv: { + patches = (drv.patches or []) ++ [ ./config.patch ]; + patchFlags = [ "-p1" "-d" "src/tools/rustfmt" ]; + DEFAULT_CONFIG_FILE = runCommand "rustfmt.conf" { + nativeBuildInputs = [ remarshal ]; + value = builtins.toJSON defaultConfig; + passAsFile = [ "value" ]; + } '' + json2toml "$valuePath" "$out" + ''; +}) |