Skip to content

Commit bc6c615

Browse files
committed
xtask: fix nix formatting
nixfmt wants to be called by arguments and does not want to walk the tree by itself.
1 parent 48295b3 commit bc6c615

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

xtask/src/main.rs

+13-5
Original file line numberDiff line numberDiff 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(_) => {

0 commit comments

Comments
 (0)