{ lib, runCommand, runCommandLocal, testers, treefmt, nixfmt, }: let inherit (treefmt) buildConfig withConfig; testEqualContents = args: testers.testEqualContents ( args // lib.optionalAttrs (builtins.isString args.expected) { expected = builtins.toFile "expected" args.expected; } ); nixfmtExampleConfig = { on-unmatched = "info"; tree-root-file = ".git/index"; formatter.nixfmt = { command = "nixfmt"; includes = [ "*.nix" ]; }; }; nixfmtExamplePackage = withConfig { settings = nixfmtExampleConfig; runtimeInputs = [ nixfmt ]; }; wellFormattedTree = runCommandLocal "well-formatted-project" { } '' mkdir "$out" cat > "$out/file.nix" < "$out/file.nix" < input.nix treefmt # Assert that input.nix now matches expected if diff -u <(printf "%s" "$expected") input.nix; then touch $out else echo echo "treefmt did not format input.nix as expected" exit 1 fi ''; }