From e39b3dac309b340dfc716f85cbf4b2099228ba9d Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 2 Oct 2020 17:20:30 +0200 Subject: [PATCH] Use pre-commit hook from pre-commit-hooks.nix --- .gitignore | 3 ++- .pre-commit-config.yaml | 6 ------ default.nix | 11 +++++++++++ shell.nix | 8 ++------ 4 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 .pre-commit-config.yaml create mode 100644 default.nix diff --git a/.gitignore b/.gitignore index 79d81df..0f6e567 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -wordclock_credentials.py +/.pre-commit-config.yaml __pycache__ +wordclock_credentials.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index d0a5a47..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,6 +0,0 @@ -repos: - - repo: https://github.com/psf/black - rev: stable - hooks: - - id: black - language_version: python3 diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..dbe1513 --- /dev/null +++ b/default.nix @@ -0,0 +1,11 @@ +let + nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master"); +in +{ + pre-commit-check = nix-pre-commit-hooks.run { + src = ./.; + hooks = { + black.enable = true; + }; + }; +} diff --git a/shell.nix b/shell.nix index f7886ab..5d14712 100644 --- a/shell.nix +++ b/shell.nix @@ -2,13 +2,9 @@ pkgs.mkShell { nativeBuildInputs = with pkgs; [ - gitAndTools.pre-commit - (python3.withPackages(ps: [ ps.virtualenv ])) + nixpkgs-fmt ]; shellHook = '' - # black’s pre-commit hook builds a wheel (zip file) for black and fails - # when the timestamp is lower than 1980 (due to zip limitations) - export SOURCE_DATE_EPOCH=315532800 - pre-commit install -f >/dev/null + ${(import ./default.nix).pre-commit-check.shellHook} ''; }