File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -309,15 +309,23 @@ fn run_fmt_project(fmt_opt: &FmtOpt) -> Result<()> {
309309 eprintln ! ( "Formatting: yml - SKIPPED" ) ;
310310 }
311311
312- // fmt nix
313- if has_cmd ( "nixfmt" ) {
312+ // fmt nix (by passing files as arguments)
313+ // `find . -name "*.nix" -type f -exec nix fmt {} \+`
314+ if has_cmd ( "find" ) && has_cmd ( "nixfmt" ) {
314315 eprintln ! ( "Formatting: nix" ) ;
315- let mut command = Command :: new ( "nixfmt" ) ;
316+ let mut command = Command :: new ( "find" ) ;
317+ command. arg ( "." ) ;
318+ command. arg ( "-name" ) ;
319+ command. arg ( "*.nix" ) ;
320+ command. arg ( "-type" ) ;
321+ command. arg ( "f" ) ;
322+ command. arg ( "-exec" ) ;
323+ command. arg ( "nixfmt" ) ;
316324 if fmt_opt. check {
317325 command. arg ( "--check" ) ;
318326 }
319- command. arg ( "nix " ) ;
320- command. arg ( "shell.nix " ) ;
327+ command. arg ( "{} " ) ;
328+ command. arg ( "+ " ) ;
321329
322330 match run_cmd ( command) {
323331 Ok ( _) => {
You can’t perform that action at this time.
0 commit comments