treefmt: flatten the config

By importing the config on the treefmt module level, it makes the config
more flat, and also compatible with non-flake-parts users.
This commit is contained in:
zimbatm 2023-04-12 10:15:26 +02:00
parent ea9e8d7489
commit c2eac1a161
No known key found for this signature in database
GPG key ID: 71BAF6D40C1D63D7
2 changed files with 43 additions and 46 deletions

View file

@ -60,9 +60,10 @@
inputs.treefmt-nix.flakeModule
./effect.nix
./shell.nix
./treefmt.nix
];
perSystem.treefmt.imports = [ ./treefmt.nix ];
flake.nixosConfigurations =
let
inherit (inputs.nixpkgs.lib) nixosSystem;

View file

@ -1,54 +1,50 @@
{
perSystem = { pkgs, ... }: {
treefmt = {
# Used to find the project root
projectRootFile = "flake.lock";
{ pkgs, ... }: {
# Used to find the project root
projectRootFile = "flake.lock";
programs.hclfmt.enable = true;
programs.hclfmt.enable = true;
programs.prettier.enable = true;
programs.prettier.enable = true;
settings.formatter = {
nix = {
command = "sh";
options = [
"-eucx"
''
for i in "$@"; do
${pkgs.lib.getExe pkgs.statix} fix "$i"
done
settings.formatter = {
nix = {
command = "sh";
options = [
"-eucx"
''
for i in "$@"; do
${pkgs.lib.getExe pkgs.statix} fix "$i"
done
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
''
"--"
];
includes = [ "*.nix" ];
excludes = [
"nix/sources.nix"
# vendored from external source
"build02/packages-with-update-script.nix"
];
};
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
''
"--"
];
includes = [ "*.nix" ];
excludes = [
"nix/sources.nix"
# vendored from external source
"build02/packages-with-update-script.nix"
];
};
prettier = {
excludes = [
"secrets.yaml"
];
};
prettier = {
excludes = [
"secrets.yaml"
];
};
python = {
command = "sh";
options = [
"-eucx"
''
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
''
"--" # this argument is ignored by bash
];
includes = [ "*.py" ];
};
};
python = {
command = "sh";
options = [
"-eucx"
''
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
''
"--" # this argument is ignored by bash
];
includes = [ "*.py" ];
};
};
}