Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
64 lines (55 loc) · 2.17 KB
/
Copy pathflake.nix
File metadata and controls
64 lines (55 loc) · 2.17 KB
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
{
description = "Seamless integration of https://pre-commit.com git hooks with Nix.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-compat = {
url = "github:NixOS/flake-compat";
flake = false;
};
outputs = { self, nixpkgs, ... }:
let
lib = nixpkgs.lib;
defaultSystems = [
"aarch64-linux"
"aarch64-darwin"
"x86_64-linux"
];
# Reuse each package set across output groups so requesting, for example,
# both checks and devShells does not evaluate the same dependencies twice.
depsFor = lib.genAttrs defaultSystems (system: rec {
# The exposed set already contains nixpkgs with our overlay.
pkgs = exposed;
exposed = import ./nix { inherit nixpkgs system; isFlakes = true; };
});
forAllSystems = fn: lib.mapAttrs (_: args: fn args) depsFor;
in
{
flakeModule = ./flake-module.nix;
templates.default = {
path = ./template;
description = ''
A template with flake-parts and nixpkgs-fmt.
'';
};
# The set of tools exposed by git-hooks.
# We use legacyPackages because not all tools are derivations that evaluate.
legacyPackages = forAllSystems ({ pkgs, exposed, ... }: exposed.tools // {
pre-commit = pkgs.pre-commit;
});
# WARN: use `legacyPackages` instead to get error messages for deprecated packages
#
# Each entry is guaranteed to be a derivation that evaluates.
# TODO: this should be deprecated as it exposes a subset of nixpkgs, which is incompatiile with the packages output.
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.checks);
lib = forAllSystems ({ exposed, ... }: { inherit (exposed) run; });
# TODO: remove and expose a `lib` function is needed
exposed = forAllSystems ({ exposed, ... }: exposed);
};
}