File tree 2 files changed +19
-3
lines changed
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ Given the following `flake.nix` example:
44
44
};
45
45
devShell = nixpkgs.legacyPackages.${system}.mkShell {
46
46
inherit (self.checks.${system}.pre-commit-check) shellHook;
47
+ buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
47
48
};
48
49
}
49
50
);
@@ -108,10 +109,13 @@ nix develop
108
109
3 . Integrate hooks to prepare environment as part of ` shell.nix ` :
109
110
110
111
``` nix
111
- (import <nixpkgs> {}).mkShell {
112
- shellHook = ''
113
- ${(import ./default.nix).pre-commit-check.shellHook}
112
+ let
113
+ pre-commit = import ./default.nix;
114
+ in (import <nixpkgs> {}).mkShell {
115
+ shellHook = ''
116
+ ${pre-commit.pre-commit-check.shellHook}
114
117
'';
118
+ buildInputs = pre-commit.pre-commit-check.enabledPackages;
115
119
}
116
120
```
117
121
Original file line number Diff line number Diff line change 131
131
lib . literalExpression or literalExample ''pre-commit-hooks.nix-pkgs.callPackage tools-dot-nix { inherit (pkgs) system; }'' ;
132
132
} ;
133
133
134
+ enabledPackages = mkOption {
135
+ type = types . list ;
136
+ description = lib . mdDoc
137
+ ''
138
+ All packages provided by hooks that are enabled.
139
+
140
+ Useful for including into the developer environment.
141
+ '' ;
142
+
143
+ default = builtins . map ( hook : hook . package ) ( lib . filter ( hook : hook . enable ) ( builtins . attrValues config . hooks ) ) ;
144
+ } ;
145
+
134
146
hooks =
135
147
mkOption {
136
148
type = types . submodule {
You can’t perform that action at this time.
0 commit comments