flake.nix: configure pre-commit

This commit is contained in:
Martin Weinelt 2025-04-23 16:51:22 +02:00
parent 1899fbe3fb
commit 41e513da64
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
3 changed files with 100 additions and 3 deletions

View file

@ -6,6 +6,11 @@
url = "github:edolstra/flake-compat";
flake = false;
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.flake-compat.follows = "flake-compat";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-24_11.url = "github:NixOS/nixpkgs/nixos-24.11";
blobs = {
@ -14,7 +19,7 @@
};
};
outputs = { self, blobs, nixpkgs, nixpkgs-24_11, ... }: let
outputs = { self, blobs, git-hooks, nixpkgs, nixpkgs-24_11, ... }: let
lib = nixpkgs.lib;
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
@ -123,7 +128,51 @@
hydraJobs.${system} = allTests // {
inherit documentation;
};
checks.${system} = allTests;
checks.${system} = allTests // {
pre-commit = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
# docs
markdownlint = {
enable = true;
settings.configuration = {
# Max line length, doesn't seem to correclty account for lines containing links
# https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
MD013 = false;
};
};
rstcheck = {
enable = true;
entry = lib.getExe pkgs.rstcheckWithSphinx;
files = "\\.rst$";
};
# nix
deadnix.enable = true;
# python
pyright.enable = true;
ruff = {
enable = true;
args = [
"--extend-select"
"I"
];
};
ruff-format.enable = true;
# scripts
shellcheck.enable = true;
# sieve
check-sieve = {
enable = true;
entry = lib.getExe pkgs.check-sieve;
files = "\\.sieve$";
};
};
};
};
packages.${system} = {
inherit optionsDoc documentation;
};
@ -131,7 +180,8 @@
inputsFrom = [ documentation ];
packages = with pkgs; [
clamav
];
] ++ self.checks.${system}.pre-commit.enabledPackages;
shellHook = self.checks.${system}.pre-commit.shellHook;
};
devShell.${system} = self.devShells.${system}.default; # compatibility
};