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
|
inputs.treefmt-nix.flakeModule
|
||||||
./effect.nix
|
./effect.nix
|
||||||
./shell.nix
|
./shell.nix
|
||||||
./treefmt.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
perSystem.treefmt.imports = [ ./treefmt.nix ];
|
||||||
|
|
||||||
flake.nixosConfigurations =
|
flake.nixosConfigurations =
|
||||||
let
|
let
|
||||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||||
|
|
86
treefmt.nix
86
treefmt.nix
|
@ -1,54 +1,50 @@
|
||||||
{
|
{ pkgs, ... }: {
|
||||||
perSystem = { pkgs, ... }: {
|
# Used to find the project root
|
||||||
treefmt = {
|
projectRootFile = "flake.lock";
|
||||||
# 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 = {
|
settings.formatter = {
|
||||||
nix = {
|
nix = {
|
||||||
command = "sh";
|
command = "sh";
|
||||||
options = [
|
options = [
|
||||||
"-eucx"
|
"-eucx"
|
||||||
''
|
''
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
${pkgs.lib.getExe pkgs.statix} fix "$i"
|
${pkgs.lib.getExe pkgs.statix} fix "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
|
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
|
||||||
''
|
''
|
||||||
"--"
|
"--"
|
||||||
];
|
];
|
||||||
includes = [ "*.nix" ];
|
includes = [ "*.nix" ];
|
||||||
excludes = [
|
excludes = [
|
||||||
"nix/sources.nix"
|
"nix/sources.nix"
|
||||||
# vendored from external source
|
# vendored from external source
|
||||||
"build02/packages-with-update-script.nix"
|
"build02/packages-with-update-script.nix"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
prettier = {
|
prettier = {
|
||||||
excludes = [
|
excludes = [
|
||||||
"secrets.yaml"
|
"secrets.yaml"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
python = {
|
python = {
|
||||||
command = "sh";
|
command = "sh";
|
||||||
options = [
|
options = [
|
||||||
"-eucx"
|
"-eucx"
|
||||||
''
|
''
|
||||||
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
|
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
|
||||||
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
|
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
|
||||||
''
|
''
|
||||||
"--" # this argument is ignored by bash
|
"--" # this argument is ignored by bash
|
||||||
];
|
];
|
||||||
includes = [ "*.py" ];
|
includes = [ "*.py" ];
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue