File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 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:
4444 };
4545 devShell = nixpkgs.legacyPackages.${system}.mkShell {
4646 inherit (self.checks.${system}.pre-commit-check) shellHook;
47+ buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
4748 };
4849 }
4950 );
@@ -108,10 +109,13 @@ nix develop
1081093 . Integrate hooks to prepare environment as part of ` shell.nix ` :
109110
110111 ``` 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}
114117 '';
118+ buildInputs = pre-commit.pre-commit-check.enabledPackages;
115119 }
116120 ```
117121
Original file line number Diff line number Diff line change 131131 lib . literalExpression or literalExample ''pre-commit-hooks.nix-pkgs.callPackage tools-dot-nix { inherit (pkgs) system; }'' ;
132132 } ;
133133
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+
134146 hooks =
135147 mkOption {
136148 type = types . submodule {
You can’t perform that action at this time.
0 commit comments