From 73ea0ac824ded84978e1b3b9653df407d83c9024 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 23 Apr 2023 03:20:58 -0400 Subject: feat: move pre-commit to nix --- flake.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 5d9942c..fa387cf 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,19 @@ { description = "silly little api"; - inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs-stable.follows = "nixpkgs"; + }; + }; outputs = { self, nixpkgs, + pre-commit-hooks, }: let version = self.lastModifiedDate; @@ -30,11 +38,30 @@ guzzle-api-server = callPackage ./nix/server.nix {}; }; in { + checks = forAllSystems (system: let + pkgs = nixpkgsFor.${system}; + in { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + isort.enable = true; + pylint.enable = true; + yapf = { + enable = true; + name = "yapf"; + entry = "${pkgs.python311Packages.yapf}/bin/yapf -i"; + types = ["file" "python"]; + }; + }; + }; + }); + devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; inherit (pkgs) mkShell; in { default = mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; packages = with pkgs.python311Packages; [ python fastapi -- cgit v1.2.3