pre-commit: stop using the flake

The flake for pre-commit-checks is rather questionable. We ignored
it so it uses our own nixpkgs and doesn't reimport nixpkgs. This should
save a couple of seconds of eval time!

Change-Id: I4584982beb32e0122f791fa29f6a544bdbb9e201
This commit is contained in:
jade 2024-04-07 20:05:19 -07:00
parent 860b34cf07
commit 6fcab7ee95
2 changed files with 23 additions and 84 deletions

View file

@ -16,45 +16,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1711481231, "lastModified": 1711481231,
@ -88,25 +49,13 @@
} }
}, },
"pre-commit-hooks": { "pre-commit-hooks": {
"inputs": { "flake": false,
"flake-compat": [
"flake-compat"
],
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1711981679, "lastModified": 1712055707,
"narHash": "sha256-pnbHEXJOdGkPrHBdkZLv/a2V09On+V3J4aPE/BfAJC8=", "narHash": "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "f3bb95498eaaa49a93bacaf196cdb6cf8e872cdf", "rev": "e35aed5fda3cc79f88ed7f1795021e559582093a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -122,21 +71,6 @@
"nixpkgs-regression": "nixpkgs-regression", "nixpkgs-regression": "nixpkgs-regression",
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -6,11 +6,7 @@
nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2"; nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
pre-commit-hooks = { pre-commit-hooks = {
url = "github:cachix/git-hooks.nix"; url = "github:cachix/git-hooks.nix";
inputs = { flake = false;
flake-compat.follows = "flake-compat";
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs";
};
}; };
flake-compat = { flake-compat = {
url = "github:edolstra/flake-compat"; url = "github:edolstra/flake-compat";
@ -301,9 +297,22 @@
); );
}; };
pre-commit = builtins.mapAttrs ( pre-commit = forAllSystems (
system: pre-commit-lib: system:
pre-commit-lib.run { let
pkgs = nixpkgsFor.${system}.native;
# Import pre-commit bypassing the flake because flakes don't let
# you have overlays. Also their implementation forces an
# unnecessary reimport of nixpkgs for our use cases.
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 = self; src = self;
hooks = { hooks = {
no-commit-to-branch = { no-commit-to-branch = {
@ -345,15 +354,11 @@
}; };
treefmt = { treefmt = {
enable = true; enable = true;
settings.formatters = settings.formatters = [ pkgs.nixfmt ];
let
pkgs = nixpkgsFor.${system}.native;
in
[ pkgs.nixfmt ];
}; };
}; };
} }
) pre-commit-hooks.lib; );
}; };
# NOTE *do not* add fresh derivations to checks, always add them to # NOTE *do not* add fresh derivations to checks, always add them to