nix-eval-jobs/dev/treefmt.nix

51 lines
1.1 KiB
Nix
Raw Normal View History

2023-07-21 01:23:16 +00:00
{ pkgs, lib, ... }: {
# Used to find the project root
projectRootFile = "flake.lock";
programs.prettier.enable = true;
programs.prettier.package = pkgs.writeShellScriptBin "prettier" ''
export NODE_PATH=${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules
2023-08-06 16:49:32 +00:00
exec ${pkgs.nodePackages.prettier}/bin/prettier "$@"
2023-07-21 01:23:16 +00:00
'';
programs.clang-format.enable = true;
settings.formatter = {
nix = {
command = "sh";
options = [
"-eucx"
''
2023-08-06 16:49:32 +00:00
${pkgs.deadnix}/bin/deadnix --edit "$@"
2023-07-21 01:24:29 +00:00
for i in "$@"; do
2023-08-06 16:49:32 +00:00
${pkgs.statix}/bin/statix fix "$i"
2023-07-21 01:24:29 +00:00
done
2023-08-06 16:49:32 +00:00
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt "$@"
2023-07-21 01:23:16 +00:00
''
"--"
];
includes = [ "*.nix" ];
excludes = [ ];
};
clang-format = { };
prettier.includes = lib.mkForce [ "*.toml" ];
python = {
command = "sh";
options = [
"-eucx"
''
2023-08-06 16:49:32 +00:00
${pkgs.python3.pkgs.black}/bin/black "$@"
${pkgs.ruff}/bin/ruff --fix "$@"
2023-07-21 01:23:16 +00:00
''
"--" # this argument is ignored by bash
];
includes = [ "*.py" ];
};
};
}