9c61d64a11
Change-Id: I235e7fcbd49f11e71127ce31da9c11da4d220ff6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4584 Autosubmit: tazjin <mail@tazj.in> Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
21 lines
589 B
Nix
21 lines
589 B
Nix
# 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"]
|
|
|
|
[formatter.tf]
|
|
command = "${pkgs.terraform}/bin/terraform"
|
|
options = [ "fmt" ]
|
|
includes = [ "*.tf" ]
|
|
'';
|
|
in pkgs.writeShellScriptBin "depotfmt" ''
|
|
exec ${pkgs.treefmt}/bin/treefmt ''${@} \
|
|
--config-file ${config} \
|
|
--tree-root $(${pkgs.git}/bin/git rev-parse --show-toplevel)
|
|
''
|