File tree Expand file tree Collapse file tree 5 files changed +35
-12
lines changed Expand file tree Collapse file tree 5 files changed +35
-12
lines changed Original file line number Diff line number Diff line change 3737 Nixpkgs to use in the pre-commit [`settings`](#opt-perSystem.pre-commit.settings).
3838 '' ;
3939 default = pkgs ;
40- defaultText = lib . literalMD "`pkgs` (module argument)" ;
40+ defaultText = lib . literalExpression "`pkgs` (module argument)" ;
4141 } ;
4242 settings = mkOption {
4343 type = types . submoduleWith {
4949 The git-hooks.nix configuration.
5050 '' ;
5151 } ;
52+ shellHook = mkOption {
53+ type = types . str ;
54+ description = "A shell hook that installs up the git hooks in a development shell." ;
55+ default = cfg . settings . installationScript ;
56+ defaultText = lib . literalExpression "bash statements" ;
57+ readOnly = true ;
58+ } ;
5259 installationScript = mkOption {
5360 type = types . str ;
54- description = "A bash fragment that sets up [pre-commit](https://pre-commit.com/) ." ;
61+ description = "A bash snippet that sets up the git hooks in the current repository ." ;
5562 default = cfg . settings . installationScript ;
56- defaultText = lib . literalMD "bash statements" ;
63+ defaultText = lib . literalExpression "bash statements" ;
5764 readOnly = true ;
5865 } ;
5966 devShell = mkOption {
6067 type = types . package ;
61- description = "A development shell with pre-commit installed and setup ." ;
68+ description = "A development shell with the git hooks installed and all the packages made available ." ;
6269 readOnly = true ;
6370 } ;
6471 } ;
7279 hooks . treefmt . package = lib . mkIf ( options ?treefmt ) ( lib . mkOverride 900 config . treefmt . build . wrapper ) ;
7380 } ;
7481 pre-commit . devShell = pkgs . mkShell {
75- nativeBuildInputs = cfg . settings . enabledPackages ++ [ cfg . settings . package ] ;
76- shellHook = cfg . installationScript ;
82+ inherit ( cfg . settings ) shellHook ;
83+ nativeBuildInputs = cfg . settings . enabledPackages ;
7784 } ;
7885 } ;
7986 } ) ;
Original file line number Diff line number Diff line change 5757 name = mkOption {
5858 type = types . str ;
5959 default = name ;
60- defaultText = lib . literalMD "the attribute name the hook submodule is bound to, same as `id`" ;
60+ defaultText = lib . literalExpression "the attribute name the hook submodule is bound to, same as `id`" ;
6161 description =
6262 ''
6363 The name of the hook. Shown during hook execution.
Original file line number Diff line number Diff line change 282282 defaultText = lib . literalExpression "<derivation>" ;
283283 } ;
284284
285+ shellHook =
286+ mkOption {
287+ type = types . str ;
288+ description =
289+ ''
290+ A shell hook that sets up the git hooks in a development shell.
291+
292+ Pass to `mkShell` as `shellHook` to use.
293+ '' ;
294+ readOnly = true ;
295+ } ;
296+
285297 installationScript =
286298 mkOption {
287299 type = types . str ;
288300 description =
289301 ''
290- A bash snippet that installs nix-pre-commit- hooks in the current directory
302+ A bash snippet that installs the git hooks in the current repository.
291303 '' ;
292304 readOnly = true ;
293305 } ;
439451 default_stages = cfg . default_stages ;
440452 } ;
441453
454+ shellHook =
455+ ''
456+ ${ config . installationScript }
457+ export PATH=${ config . package } /bin:$PATH
458+ '' ;
459+
442460 installationScript =
443461 ''
444462 if ${ boolToString cfg . install . enable } ; then
Original file line number Diff line number Diff line change 2828 }
2929 ] ++ imports ;
3030 } ;
31- inherit ( project . config ) installationScript ;
3231
3332in
3433project . config . run // {
3534 inherit ( project ) config ;
36- inherit ( project . config ) enabledPackages ;
37- shellHook = installationScript ;
35+ inherit ( project . config ) enabledPackages shellHook ;
3836}
Original file line number Diff line number Diff line change 2727 # NOTE: You can also use `config.pre-commit.devShell`
2828 devShells . default = pkgs . mkShell {
2929 shellHook = ''
30- ${ config . pre-commit . installationScript }
30+ ${ config . pre-commit . shellHook }
3131 echo 1>&2 "Welcome to the development shell!"
3232 '' ;
3333
You can’t perform that action at this time.
0 commit comments