diff --git a/Home.md b/Home.md index 9a1a232..4e3f289 100644 --- a/Home.md +++ b/Home.md @@ -134,4 +134,25 @@ done "--", ] includes = ["*.tf"] +``` + +## Using treefmt in a nix-build + +```nix +{ src # src should point to the project to check the format for +, runCommandNoCC +, shfmt +, rustfmt +, treefmt +}: +runCommandNoCC "treefmt" { + # add all your formatters here + nativeBuildInputs = [ shfmt rustfmt treefmt ]; +} '' + # keep timestamps so that treefmt is able to detect mtime changes + cp --no-preserve=mode --preserve=timestamps -r ${src} source + cd source + HOME=$TMPDIR treefmt --fail-on-change + touch $out +''; ``` \ No newline at end of file