Skip to content

Commit 2a2b75f

Browse files
committed
docs: document nix develop -c
`nix flake check` is a common source of frustration and most don't realize that they can use hooks without it.
1 parent 3ff4596 commit 2a2b75f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
- Provide a low-overhead build of all the tooling available for the hooks to use
1010
(naive implementation of calling nix-shell does bring some latency when committing)
1111

12-
- **Common hooks for languages** like Python, Haskell, Elm, etc. [see all hook options](https://devenv.sh/?q=pre-commit.hooks)
12+
- **Common hooks for languages** like Python, Haskell, Elm, etc. [See all hook options](https://devenv.sh/?q=git-hooks.hooks)
1313

14-
- Run hooks **as part of development** and **on during CI**
14+
- Run hooks **as part of development** and **during CI**
1515

1616
## Getting started
1717

@@ -81,18 +81,26 @@ Given the following `flake.nix` example:
8181
}
8282
```
8383

84-
Add `/.pre-commit-config.yaml` to the `.gitignore`.
84+
Add `/.pre-commit-config.yaml` to `.gitignore`.
85+
This file is auto-generated from the Nix configuration and doesn't need to be committed.
8586

86-
To run the all the hooks on CI:
87+
Enter a development shell with pre-commit hooks enabled:
8788

88-
```bash
89+
```shell
90+
nix develop
91+
```
92+
93+
Run all hooks sandboxed (no internet access):
94+
95+
```shell
8996
nix flake check
9097
```
9198

92-
To install pre-commit hooks developers would run:
99+
Some hooks require access to the internet or local filesystem, which is not possible when using `nix flake check`.
100+
If the hook doesn't expose options to pre-package its impure access or it's too cumbersome to do so, you can run `pre-commit` through `nix develop` instead:
93101

94-
```bash
95-
nix develop
102+
```shell
103+
nix develop -c pre-commit run -a
96104
```
97105

98106
### flake-parts

0 commit comments

Comments
 (0)