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

master
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__
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 {
nativeBuildInputs = with pkgs; [
gitAndTools.pre-commit
(python3.withPackages(ps: [ ps.virtualenv ]))
nixpkgs-fmt
];
shellHook = ''
# blacks 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}
'';
}