nix-eval-jobs/dev/treefmt.nix

50 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
exec ${lib.getExe pkgs.nodePackages.prettier} "$@"
'';
programs.clang-format.enable = true;
settings.formatter = {
nix = {
command = "sh";
options = [
"-eucx"
''
2023-07-21 01:24:29 +00:00
${pkgs.lib.getExe pkgs.deadnix} --edit "$@"
for i in "$@"; do
${pkgs.lib.getExe pkgs.statix} fix "$i"
done
2023-07-21 01:23:16 +00:00
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
''
"--"
];
includes = [ "*.nix" ];
excludes = [ ];
};
clang-format = { };
prettier.includes = lib.mkForce [ "*.toml" ];
python = {
command = "sh";
options = [
"-eucx"
''
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
''
"--" # this argument is ignored by bash
];
includes = [ "*.py" ];
};
};
}