treefmt: refactor, treefmt2, pipelines
also move editorconfig to a separate check as it isn't currently compatible with treefmt pipelines
This commit is contained in:
parent
b99ce5a608
commit
a7547585c9
4 changed files with 57 additions and 44 deletions
|
@ -5,3 +5,7 @@ end_of_line = lf
|
|||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
|
||||
[*.age]
|
||||
end_of_line = unset
|
||||
insert_final_newline = unset
|
||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -6,9 +6,5 @@ result-*
|
|||
.terraform
|
||||
.terraform.*
|
||||
|
||||
# needed for treefmt
|
||||
!.github
|
||||
!.sops.yaml
|
||||
|
||||
# direnv
|
||||
.direnv/
|
||||
|
|
|
@ -2,14 +2,24 @@
|
|||
# Used to find the project root
|
||||
projectRootFile = ".git/config";
|
||||
|
||||
programs.hclfmt.enable = true;
|
||||
package = pkgs.treefmt2;
|
||||
|
||||
programs = {
|
||||
deadnix.enable = true;
|
||||
hclfmt.enable = true;
|
||||
nixpkgs-fmt.enable = true;
|
||||
prettier.enable = true;
|
||||
ruff.check = true;
|
||||
ruff.format = true;
|
||||
statix.enable = true;
|
||||
};
|
||||
|
||||
programs.mypy = {
|
||||
enable = true;
|
||||
directories = {
|
||||
"tasks" = {
|
||||
directory = ".";
|
||||
files = [ "**/tasks.py" ];
|
||||
files = [ "*tasks.py" ];
|
||||
modules = [ ];
|
||||
extraPythonPackages = [
|
||||
pkgs.python3.pkgs.deploykit
|
||||
|
@ -19,41 +29,47 @@
|
|||
};
|
||||
};
|
||||
|
||||
programs.prettier.enable = true;
|
||||
settings.global.excludes = [
|
||||
# vendored from external source
|
||||
"hosts/build02/packages-with-update-script.nix"
|
||||
];
|
||||
|
||||
settings.formatter = {
|
||||
actionlint = {
|
||||
command = pkgs.actionlint;
|
||||
includes = [ ".github/workflows/*.yml" ];
|
||||
pipeline = "yaml";
|
||||
priority = 1;
|
||||
};
|
||||
|
||||
editorconfig-checker = {
|
||||
command = pkgs.editorconfig-checker;
|
||||
includes = [ "*" ];
|
||||
excludes = [ "*.age" ];
|
||||
deadnix = {
|
||||
pipeline = "nix";
|
||||
priority = 1;
|
||||
};
|
||||
|
||||
nix = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
${pkgs.lib.getExe pkgs.deadnix} --edit "$@"
|
||||
statix = {
|
||||
pipeline = "nix";
|
||||
priority = 2;
|
||||
};
|
||||
|
||||
for i in "$@"; do
|
||||
${pkgs.lib.getExe pkgs.statix} fix "$i"
|
||||
done
|
||||
nixpkgs-fmt = {
|
||||
pipeline = "nix";
|
||||
priority = 3;
|
||||
};
|
||||
|
||||
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
|
||||
''
|
||||
"--"
|
||||
];
|
||||
includes = [ "*.nix" ];
|
||||
excludes = [
|
||||
"nix/sources.nix"
|
||||
# vendored from external source
|
||||
"hosts/build02/packages-with-update-script.nix"
|
||||
];
|
||||
ruff-check = {
|
||||
pipeline = "python";
|
||||
priority = 1;
|
||||
};
|
||||
|
||||
ruff-format = {
|
||||
pipeline = "python";
|
||||
priority = 2;
|
||||
};
|
||||
|
||||
mypy-tasks = {
|
||||
pipeline = "python";
|
||||
priority = 3;
|
||||
};
|
||||
|
||||
prettier = {
|
||||
|
@ -63,21 +79,10 @@
|
|||
"never"
|
||||
];
|
||||
excludes = [
|
||||
"secrets.yaml"
|
||||
"*secrets.yaml"
|
||||
];
|
||||
};
|
||||
|
||||
python = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
${pkgs.lib.getExe pkgs.ruff} check --fix "$@"
|
||||
${pkgs.lib.getExe pkgs.ruff} format "$@"
|
||||
''
|
||||
"--" # this argument is ignored by bash
|
||||
];
|
||||
includes = [ "*.py" ];
|
||||
pipeline = "yaml";
|
||||
priority = 2;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -99,6 +99,14 @@
|
|||
cd ${self}
|
||||
mkdocs build --strict --site-dir $out
|
||||
'';
|
||||
editorconfig = pkgs.runCommand "editorconfig"
|
||||
{
|
||||
buildInputs = [ pkgs.editorconfig-checker ];
|
||||
} ''
|
||||
cd ${self}
|
||||
editorconfig-checker
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue