forked from cachix/git-hooks.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
61 lines (53 loc) · 1.97 KB
/
flake.nix
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
{
description = "Seamless integration of https://pre-commit.com git hooks with Nix.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, gitignore, nixpkgs-stable, ... }:
let
lib = nixpkgs.lib;
defaultSystems = [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
depsFor = lib.genAttrs defaultSystems (system: {
pkgs = nixpkgs.legacyPackages.${system};
exposed = import ./nix { inherit nixpkgs system; gitignore-nix-src = gitignore; isFlakes = true; };
exposed-stable = import ./nix { nixpkgs = nixpkgs-stable; inherit system; gitignore-nix-src = gitignore; isFlakes = true; };
});
forAllSystems = fn: lib.genAttrs defaultSystems (system: fn depsFor.${system});
in
{
flakeModule = ./flake-module.nix;
templates.default = {
path = ./template;
description = ''
A template with flake-parts and nixpkgs-fmt.
'';
};
packages = forAllSystems ({ exposed, ... }: exposed.packages // {
default = exposed.packages.pre-commit;
});
devShells = forAllSystems ({ pkgs, exposed, ... }: {
default = pkgs.mkShellNoCC {
inherit (exposed.checks.pre-commit-check) shellHook;
};
});
checks = forAllSystems ({ exposed, exposed-stable, ... }:
lib.filterAttrs (k: v: v != null)
(exposed.checks
// (lib.mapAttrs' (name: value: lib.nameValuePair "stable-${name}" value)
exposed-stable.checks)));
lib = forAllSystems ({ exposed, ... }: { inherit (exposed) run; });
exposed = forAllSystems ({ exposed, ... }: exposed);
};
}