Use pre-commit hook from pre-commit-hooks.nix

This commit is contained in:
Simon Bruder 2020-10-02 17:20:30 +02:00
parent f8cf89b532
commit e39b3dac30
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
4 changed files with 15 additions and 13 deletions

3
.gitignore vendored
View file

@ -1,2 +1,3 @@
wordclock_credentials.py /.pre-commit-config.yaml
__pycache__ __pycache__
wordclock_credentials.py

View file

@ -1,6 +0,0 @@
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3

11
default.nix Normal file
View file

@ -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;
};
};
}

View file

@ -2,13 +2,9 @@
pkgs.mkShell { pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
gitAndTools.pre-commit nixpkgs-fmt
(python3.withPackages(ps: [ ps.virtualenv ]))
]; ];
shellHook = '' shellHook = ''
# blacks pre-commit hook builds a wheel (zip file) for black and fails ${(import ./default.nix).pre-commit-check.shellHook}
# when the timestamp is lower than 1980 (due to zip limitations)
export SOURCE_DATE_EPOCH=315532800
pre-commit install -f >/dev/null
''; '';
} }