about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/depotfmt.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/depotfmt.nix b/tools/depotfmt.nix
new file mode 100644
index 000000000000..097bc29b4595
--- /dev/null
+++ b/tools/depotfmt.nix
@@ -0,0 +1,16 @@
+# Builds treefmt for depot, with a hardcoded configuration that
+# includes the right paths to formatters.
+{ pkgs, ... }:
+
+let
+  config = pkgs.writeText "depot-treefmt-config" ''
+    [formatter.go]
+    command = "${pkgs.go}/bin/gofmt"
+    options = [ "-w" ]
+    includes = ["*.go"]
+  '';
+in pkgs.writeShellScriptBin "depotfmt" ''
+  exec ${pkgs.treefmt}/bin/treefmt ''${@} \
+    --config-file ${config} \
+    --tree-root $(${pkgs.git}/bin/git rev-parse --show-toplevel)
+''