blob: 6a8642edd866f39095ff671c009197bf5efe9f1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# Separate flake for validation, since we don't want to make these visible to users
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
flake = false;
};
outputs =
{
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
}:
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
checks = self.checks.${system};
in
{
devShells.default = pkgs.mkShell {
shellHook = ''
${nixpkgs.lib.optionalString (checks.pre-commit ? shellHook) checks.pre-commit.shellHook}
'';
nativeBuildInputs = with pkgs.buildPackages; [
treefmt
nixfmt-rfc-style
ruff
python3
python3Packages.pytest
python3Packages.aiohttp
];
};
checks.pre-commit =
let
# Avoid an unnecessary reimport of nixpkgs
tools = import (pre-commit-hooks + "/nix/call-tools.nix") pkgs;
pre-commit-run = pkgs.callPackage (pre-commit-hooks + "/nix/run.nix") {
inherit tools;
isFlakes = true;
# unused!
gitignore-nix-src = builtins.throw "gitignore-nix-src is unused";
};
in
pre-commit-run {
src = ../.;
hooks = {
treefmt = {
enable = true;
settings.formatters = with pkgs.buildPackages; [
ruff
nixfmt-rfc-style
];
};
};
};
}
));
}
|