infra/dev/treefmt.nix

78 lines
1.5 KiB
Nix
Raw Normal View History

{ pkgs, ... }: {
# Used to find the project root
2023-09-20 09:08:21 +10:00
projectRootFile = ".git/config";
2022-12-31 07:18:49 +01:00
programs.hclfmt.enable = true;
2022-12-31 07:18:49 +01:00
2023-09-06 11:41:05 +10:00
programs.mypy = {
enable = true;
directories = {
"tasks" = {
directory = ".";
files = [ "**/tasks.py" ];
modules = [ ];
extraPythonPackages = [
pkgs.python3.pkgs.deploykit
pkgs.python3.pkgs.invoke
];
};
};
};
programs.prettier.enable = true;
2023-03-13 13:23:27 +10:00
settings.formatter = {
2023-09-15 16:08:20 +10:00
actionlint = {
command = pkgs.actionlint;
includes = [ ".github/workflows/*.yml" ];
};
nix = {
command = "sh";
options = [
"-eucx"
''
2023-04-12 13:24:49 +10:00
${pkgs.lib.getExe pkgs.deadnix} --edit "$@"
for i in "$@"; do
${pkgs.lib.getExe pkgs.statix} fix "$i"
done
2023-01-01 21:18:13 +01:00
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
''
"--"
];
includes = [ "*.nix" ];
excludes = [
"nix/sources.nix"
# vendored from external source
2023-05-18 13:24:26 +10:00
"hosts/build02/packages-with-update-script.nix"
];
};
2022-12-31 07:18:49 +01:00
prettier = {
2023-08-08 08:56:46 +10:00
options = [
"--write"
"--prose-wrap"
"never"
];
excludes = [
"secrets.yaml"
];
};
2023-03-13 13:23:27 +10:00
python = {
command = "sh";
options = [
"-eucx"
''
2024-05-05 15:38:04 +10:00
${pkgs.lib.getExe pkgs.ruff} check --fix "$@"
2023-10-30 11:15:45 +10:00
${pkgs.lib.getExe pkgs.ruff} format "$@"
''
"--" # this argument is ignored by bash
];
includes = [ "*.py" ];
2022-12-31 07:18:49 +01:00
};
};
}