flake.nix: Add and configure treefmt-nix for nix fmt

This commit is contained in:
Thomas Preisner 2024-12-07 12:55:51 +01:00
parent d5107df08d
commit 6f1964e6f2
2 changed files with 37 additions and 3 deletions

View file

@ -5,6 +5,8 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
git-hooks-nix.url = "github:cachix/git-hooks.nix";
git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
};
@ -21,6 +23,7 @@
"aarch64-linux"
];
imports = [
inputs.treefmt-nix.flakeModule
inputs.git-hooks-nix.flakeModule
];
@ -43,7 +46,7 @@
devShells.default = pkgs.mkShell {
packages = with pkgs; [
alejandra
self'.formatter.outPath # Add all formatters to environment
];
shellHook = ''
${config.pre-commit.installationScript}
@ -51,7 +54,17 @@
};
pre-commit.settings.hooks = {
alejandra.enable = true;
treefmt.enable = true;
};
treefmt = {
programs = {
alejandra.enable = true;
};
settings.global.excludes = [
".envrc"
"*.sieve"
];
};
};