nix-update/treefmt.nix
2023-11-02 09:26:15 +00:00

47 lines
1.0 KiB
Nix

{ lib, inputs, ... }: {
imports = [
inputs.treefmt-nix.flakeModule
];
perSystem = { pkgs, ... }: {
treefmt = {
# Used to find the project root
projectRootFile = "flake.lock";
programs.prettier.enable = true;
programs.mypy.enable = true;
settings.formatter = {
nix = {
command = "sh";
options = [
"-eucx"
''
# First deadnix
${lib.getExe pkgs.deadnix} --edit "$@"
# Then nixpkgs-fmt
${lib.getExe pkgs.nixpkgs-fmt} "$@"
''
"--"
];
includes = [ "*.nix" ];
excludes = [ "nix/sources.nix" ];
};
python = {
command = "sh";
options = [
"-eucx"
''
${lib.getExe pkgs.ruff} --fix "$@"
${lib.getExe pkgs.ruff} format "$@"
''
"--" # this argument is ignored by bash
];
includes = [ "*.py" ];
};
};
};
};
}