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:
parent
ea9e8d7489
commit
c2eac1a161
2 changed files with 43 additions and 46 deletions
|
@ -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;
|
||||
|
|
86
treefmt.nix
86
treefmt.nix
|
@ -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" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue