Document direnv exec for non-interactive runs
Prefer `direnv exec .` (cached dev shell) over `nix develop --command`, which re-evaluates the flake every call. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -24,15 +24,24 @@ token helper, and the Home Assistant custom component itself (see Integration).
|
|||||||
|
|
||||||
## Dev environment
|
## Dev environment
|
||||||
|
|
||||||
Nix flake + nix-direnv. `direnv allow` (or `nix develop`) enters a shell with
|
Nix flake + nix-direnv. `direnv allow` enters a shell with `mitmproxy`/`python`.
|
||||||
`mitmproxy`. There is no `python3` on PATH outside the shell — run Python via
|
|
||||||
`nix develop --command python ...`.
|
To run Python/mitmproxy from a non-interactive shell (where direnv does **not**
|
||||||
|
auto-activate and there's no `python` on PATH), use `direnv exec .`:
|
||||||
|
|
||||||
|
```
|
||||||
|
direnv exec . python script.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This reuses nix-direnv's **cached** dev shell (~0.06s). Prefer it over
|
||||||
|
`nix develop --command ...`, which re-evaluates the flake every call (slow, and
|
||||||
|
noisy with "Git tree is dirty" warnings).
|
||||||
|
|
||||||
Gotchas:
|
Gotchas:
|
||||||
- Nix flakes only see **git-tracked** files. `git add` new files before
|
- Nix flakes only see **git-tracked** files. `git add` new files before
|
||||||
`nix develop` / `nix flake lock`, or Nix errors with "not tracked by Git".
|
`nix develop` / `nix flake lock`, or Nix errors with "not tracked by Git".
|
||||||
- `nix develop --command` may change cwd — use **absolute paths** when a script
|
- Use **absolute paths** when a script opens `android-flows.mitm` — `nix develop
|
||||||
opens `android-flows.mitm`.
|
--command` resets cwd to the repo root (`direnv exec .` keeps the current dir).
|
||||||
|
|
||||||
## Code style
|
## Code style
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user