diff options
-rwxr-xr-x | bin/__dispatch.sh | 3 | ||||
l--------- | bin/depotfmt | 1 | ||||
-rw-r--r-- | third_party/overlays/tvl.nix | 17 | ||||
-rw-r--r-- | tools/depotfmt.nix | 16 |
4 files changed, 37 insertions, 0 deletions
diff --git a/bin/__dispatch.sh b/bin/__dispatch.sh index c4d8b5991987..6eb24beaf5c6 100755 --- a/bin/__dispatch.sh +++ b/bin/__dispatch.sh @@ -58,6 +58,9 @@ case "${TARGET_TOOL}" in stern) attr="third_party.nixpkgs.stern" ;; + depotfmt) + attr="tools.depotfmt" + ;; *) echo "The tool '${TARGET_TOOL}' is currently not installed in this repository." exit 1 diff --git a/bin/depotfmt b/bin/depotfmt new file mode 120000 index 000000000000..8390ec9c9652 --- /dev/null +++ b/bin/depotfmt @@ -0,0 +1 @@ +__dispatch.sh \ No newline at end of file diff --git a/third_party/overlays/tvl.nix b/third_party/overlays/tvl.nix index 80f337200176..df21e8819bbe 100644 --- a/third_party/overlays/tvl.nix +++ b/third_party/overlays/tvl.nix @@ -59,4 +59,21 @@ self: super: { mkShell = super.lib.makeOverridable(args: (super.mkShell args) // { meta.ci = false; }); + + # bump treefmt to a newer version that includes our config file patch + treefmt = super.treefmt.overrideAttrs(drv: rec { + version = "0.3.0"; + + src = super.fetchFromGitHub { + owner = "numtide"; + repo = "treefmt"; + rev = "v${version}"; + sha256 = "0jnfak6wmqpqwymja9bsw54al50yqzdy7lxfx66rqamqsvngqd1x"; + }; + + cargoDeps = drv.cargoDeps.overrideAttrs(_: { + inherit src; + outputHash = "19p15gavcjldn1di7yyn80ys6rj4ajaprqk8x34vxslr4y2qychf"; + }); + }); } 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) +'' |