Files
archived-hipudding-teslamate/nix/flake-modules/formatter.nix
scottbot95 dffdea99ef refactor: Cleanup nix code (#4265)
* refactor: Extract package creation to separate flake-module

* refactor: move module.nix to nix folder

* refactor: extract checks into their own flake module

* refactor: extract devShell into its own flake module

* refactor: Extract nix dev dependencies to a separate partition

* fix: spelling error

* fix: Checks break on darwin

Looks like `mkIf` doesn't work properly with flake-parts/perSystem

* fix: Remove partitions to make `devenv up` work

RIP partitions :(

* style: linter findings

---------

Co-authored-by: Jakob Lichterfeld <jakob-lichterfeld@gmx.de>
2024-10-21 15:40:49 +02:00

67 lines
1.9 KiB
Nix

{ inputs, ... }:
{
imports = [
inputs.treefmt-nix.flakeModule
];
perSystem =
{ config, pkgs, ... }:
{
# Auto formatters. This also adds a flake check to ensure that the
# source tree was auto formatted.
treefmt = {
flakeFormatter = true; # Enables treefmt the default formatter used by the nix fmt command
flakeCheck = false; # Add a flake check to run treefmt, disabled, as mix format does need the dependencies fetched beforehand
projectRootFile = "VERSION"; # File used to identity repo root
# we really need to mirror the treefmt.toml as we can't use it directly
settings.global.excludes = [
"*.gitignore"
"*.dockerignore"
".envrc"
"*.node-version"
"Dockerfile"
"grafana/Dockerfile"
"Makefile"
"VERSION"
"LICENSE"
"*.metadata"
"*.manifest"
"*.webmanifest"
"*.dat"
"*.lock"
"*.txt"
"*.csv"
"*.ico"
"*.png"
"*.svg"
"*.properties"
"*.xml"
"*.po"
"*.pot"
"*.json.example"
"*.typos.toml"
"treefmt.toml"
"grafana/dashboards/*.json" # we use the grafana export style
];
programs.mix-format.enable = true;
settings.formatter.mix-format.includes = [
"*.ex"
"*.exs"
"*.{heex,eex}"
];
# run shellcheck first
programs.shellcheck.enable = true;
settings.formatter.shellcheck.priority = 0; # default is 0, but we set it here for clarity
# shfmt second
programs.shfmt.enable = true;
programs.shfmt.indent_size = 0; # 0 means tabs
settings.formatter.shfmt.priority = 1;
programs.prettier.enable = true;
programs.nixpkgs-fmt.enable = true;
};
};
}