Skip to content

Commit 450cc45

Browse files
committed
docs: mention environment vars used to control NH in README
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a6964805cda7a29dd5e0d0cdb252ccb346c50
1 parent def8fe0 commit 450cc45

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,54 @@ The config would look like this:
215215
}
216216
```
217217

218+
## Environment variables
219+
220+
NH supports several environment variables to control command behaviour. Some of
221+
the common variables that you may encounter or choose to employ are as follows:
222+
223+
- `NH_NO_CHECKS`
224+
- When set (any non-empty value), skips startup checks such as Nix version and
225+
experimental feature validation. Useful for generating completions or
226+
running in constrained build environments. You can also consider this an
227+
"expert flag" that you can set for a non-zero performance benefit. It
228+
assumes you know what you are doing.
229+
230+
- `NH_FLAKE`
231+
- Preferred flake path/reference used by NH when running flake-based commands.
232+
Historically `FLAKE` was used; NH will migrate `FLAKE` into `NH_FLAKE` if
233+
present and the specific `NH_*_FLAKE` vars are not set.
234+
235+
- `NH_OS_FLAKE`, `NH_HOME_FLAKE`, `NH_DARWIN_FLAKE`
236+
- Command-specific flake references for `os`, `home`, and `darwin` commands
237+
respectively. If present they take precedence over `NH_FLAKE`.
238+
239+
- `NH_SUDO_ASKPASS`
240+
- Path to a program used as `SUDO_ASKPASS` when NH self-elevates with `sudo`.
241+
If set and `sudo` is used for elevation, NH will pass `-A` to `sudo` and set
242+
`SUDO_ASKPASS` accordingly.
243+
244+
- `NH_PRESERVE_ENV`
245+
- Controls whether environment variables marked for preservation are passed to
246+
elevated commands. Set to `"0"` to disable preservation, `"1"` to force
247+
preservation. If unset, preservation defaults to enabled.
248+
249+
- `NH_LOG`
250+
- Sets the tracing/log filter for NH. This uses the same format as
251+
`tracing_subscriber` env filters (for example: `nh=trace`).
252+
253+
- `NH_NOM`
254+
- Control whether `nom` (nix-output-monitor) should be enabled for the build
255+
processes. Equivalent of `--no-nom`.
256+
257+
### Notes
258+
259+
- Any environment variables prefixed with `NH_` are explicitly propagated by NH
260+
to commands when appropriate.
261+
- For backwards compatibility, if `FLAKE` is present and none of the
262+
command-specific `NH_*_FLAKE` variables exist, NH will set `NH_FLAKE` from
263+
`FLAKE` and emit a warning recommending migration to `NH_FLAKE`. `FLAKE` will
264+
be removed in the future versions of NH.
265+
218266
## Hacking
219267

220268
Contributions are always welcome. To get started, just clone the repository and

0 commit comments

Comments
 (0)