diff options
Diffstat (limited to 'tools/depotfmt.nix')
-rw-r--r-- | tools/depotfmt.nix | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/tools/depotfmt.nix b/tools/depotfmt.nix index 706b7c05a5a4..7c45f8be44b4 100644 --- a/tools/depotfmt.nix +++ b/tools/depotfmt.nix @@ -1,24 +1,14 @@ # Builds treefmt for depot, with a hardcoded configuration that # includes the right paths to formatters. -{ depot, pkgs, ... }: +{ pkgs, ... }: let - # terraform fmt can't handle multiple paths at once, but treefmt - # expects this - terraformat = pkgs.writeShellScript "terraformat" '' - echo "$@" | xargs -n1 ${pkgs.terraform}/bin/terraform fmt - ''; - config = pkgs.writeText "depot-treefmt-config" '' [formatter.go] - command = "${depot.nix.buildGo.go}/bin/gofmt" + command = "${pkgs.go}/bin/gofmt" options = [ "-w" ] includes = ["*.go"] - [formatter.tf] - command = "${terraformat}" - includes = [ "*.tf" ] - [formatter.nix] command = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" includes = [ "*.nix" ] @@ -28,8 +18,10 @@ let [formatter.rust] command = "${pkgs.rustfmt}/bin/rustfmt" + options = ["--edition", "2021"] includes = [ "*.rs" ] excludes = [ + "users/emery/*", "users/tazjin/*", ] ''; @@ -37,23 +29,28 @@ let # helper tool for formatting the depot interactively depotfmt = pkgs.writeShellScriptBin "depotfmt" '' exec ${pkgs.treefmt}/bin/treefmt ''${@} \ - --config-file ${config} \ + --on-unmatched=debug \ + --config-file=${config} \ --tree-root $(${pkgs.git}/bin/git rev-parse --show-toplevel) ''; # wrapper script for running formatting checks in CI check = pkgs.writeShellScript "depotfmt-check" '' ${pkgs.treefmt}/bin/treefmt \ - --clear-cache \ + --no-cache \ + --on-unmatched=debug \ --fail-on-change \ - --config-file ${config} \ - --tree-root . + --config-file=${config} \ + --tree-root=. ''; in depotfmt.overrideAttrs (_: { - passthru.meta.ci.extraSteps.check = { - label = "depot formatting check"; - command = check; - alwaysRun = true; + passthru = { + inherit config check; + meta.ci.extraSteps.check = { + label = "depot formatting check"; + command = check; + alwaysRun = true; + }; }; }) |