chore: setup treefmt and pre-commit

This commit is contained in:
Callum Leslie 2024-09-11 09:00:57 +01:00
parent cae2526833
commit 1c5a478ad4
Signed by: cleslie
GPG key ID: D382C4AFEECEAA90
3 changed files with 107 additions and 0 deletions

View file

@ -19,6 +19,11 @@
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
@ -28,11 +33,16 @@
} @ inputs:
flake-parts.lib.mkFlake {inherit self inputs;} {
systems = import inputs.systems;
imports = [
inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
perSystem = {
pkgs,
inputs',
self',
config,
...
}: let
rustToolchain = inputs'.fenix.packages.fromToolchainFile {
@ -74,8 +84,27 @@
devShells.default = craneLib.devShell {
inherit (self') checks;
inputsFrom = [config.pre-commit.devShell config.treefmt.build.devShell];
packages = [];
};
pre-commit = {
check.enable = false;
settings.hooks = {
alejandra.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
};
};
treefmt.config = {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
};
};
};
};