diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | .pre-commit-config.yaml | 20 | ||||
| -rw-r--r-- | flake.lock | 81 | ||||
| -rw-r--r-- | flake.nix | 29 |
4 files changed, 109 insertions, 22 deletions
@@ -161,3 +161,4 @@ cython_debug/ # nix result +.pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 6e0c147..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,20 +0,0 @@ -repos: -- repo: https://github.com/pycqa/isort - rev: 5.11.2 - hooks: - - id: isort - name: isort (python) - -- repo: local - hooks: - - id: pylint - name: pylint - entry: pylint - language: system - types: [python] - -- repo: https://github.com/pre-commit/mirrors-yapf - rev: "v0.32.0" # Use the sha / tag you want to point at - hooks: - - id: yapf - additional_dependencies: ["toml"] @@ -1,5 +1,57 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1681920287, @@ -15,9 +67,36 @@ "type": "indirect" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1681831107, + "narHash": "sha256-pXl3DPhhul9NztSetUJw2fcN+RI3sGOYgKu29xpgnqw=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "b7ca8f6fff42f6af75c17f9438fed1686b7d855d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" } } }, @@ -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 |
