Ajoute pre-commit

This commit is contained in:
Tom Hubrecht 2023-01-31 13:42:12 +01:00
parent 4606dbe9c2
commit a3de7cfc1e
2 changed files with 15 additions and 0 deletions

1
.pre-commit-config.yaml Symbolic link
View file

@ -0,0 +1 @@
/nix/store/dgy2h0brl87k6f8vsn5y15nvb383kj39-pre-commit-config.json

View file

@ -1,6 +1,16 @@
{ pkgs ? import <nixpkgs> { }, ... }:
let
nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
pre-commit-check = nix-pre-commit-hooks.run {
src = ./.;
hooks = {
black.enable = true;
isort.enable = true;
flake8.enable = true;
};
};
mkSetup = self: super: pkg: super.${pkg}.overridePythonAttrs (old: { buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools ]; });
poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
@ -21,4 +31,8 @@ pkgs.mkShell {
pkgs.poetry
poetryEnv
];
shellHook = ''
${pre-commit-check.shellHook}
'';
}