From a3de7cfc1e24b1cd89547b9fd4a95e97820e98c5 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 31 Jan 2023 13:42:12 +0100 Subject: [PATCH] Ajoute pre-commit --- .pre-commit-config.yaml | 1 + shell.nix | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 120000 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 120000 index 0000000..49aee4f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +/nix/store/dgy2h0brl87k6f8vsn5y15nvb383kj39-pre-commit-config.json \ No newline at end of file diff --git a/shell.nix b/shell.nix index ff6d548..4246825 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,16 @@ { pkgs ? import { }, ... }: 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} + ''; }