File tree 1 file changed +13
-5
lines changed
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<()> {
309
309
eprintln ! ( "Formatting: yml - SKIPPED" ) ;
310
310
}
311
311
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" ) {
314
315
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" ) ;
316
324
if fmt_opt. check {
317
325
command. arg ( "--check" ) ;
318
326
}
319
- command. arg ( "nix " ) ;
320
- command. arg ( "shell.nix " ) ;
327
+ command. arg ( "{} " ) ;
328
+ command. arg ( "+ " ) ;
321
329
322
330
match run_cmd ( command) {
323
331
Ok ( _) => {
You can’t perform that action at this time.
0 commit comments