aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-04-07 20:05:19 -0700
committerJade Lovelace <lix@jade.fyi>2024-04-08 15:29:23 -0700
commit6fcab7ee9528123e0f115e6d79ea694bca6cd426 (patch)
tree1b45b576be2240acc1b97db062f5fbec84037f22 /flake.nix
parent860b34cf07661f4ed0fe038a3a7d8b83296e2ad2 (diff)
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
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix33
1 files changed, 19 insertions, 14 deletions
diff --git a/flake.nix b/flake.nix
index 0e52695f3..b8a5da33f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,11 +6,7 @@
nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
- inputs = {
- flake-compat.follows = "flake-compat";
- nixpkgs.follows = "nixpkgs";
- nixpkgs-stable.follows = "nixpkgs";
- };
+ flake = false;
};
flake-compat = {
url = "github:edolstra/flake-compat";
@@ -301,9 +297,22 @@
);
};
- pre-commit = builtins.mapAttrs (
- system: pre-commit-lib:
- pre-commit-lib.run {
+ pre-commit = forAllSystems (
+ system:
+ 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;
hooks = {
no-commit-to-branch = {
@@ -345,15 +354,11 @@
};
treefmt = {
enable = true;
- settings.formatters =
- let
- pkgs = nixpkgsFor.${system}.native;
- in
- [ pkgs.nixfmt ];
+ settings.formatters = [ pkgs.nixfmt ];
};
};
}
- ) pre-commit-hooks.lib;
+ );
};
# NOTE *do not* add fresh derivations to checks, always add them to