mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
Clean up documentation for tracked files
This commit is contained in:
parent
bb63ffabe9
commit
b1b717221a
2 changed files with 42 additions and 12 deletions
52
README.md
52
README.md
|
|
@ -113,7 +113,7 @@ In `/etc/nixos/configuration.nix`:
|
||||||
environment.pathsToLink = [
|
environment.pathsToLink = [
|
||||||
"/share/nix-direnv"
|
"/share/nix-direnv"
|
||||||
];
|
];
|
||||||
# if you also want support for flakes
|
# if you also want support for flakes
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(self: super: { nix-direnv = super.nix-direnv.override { enableFlakes = true; }; } )
|
(self: super: { nix-direnv = super.nix-direnv.override { enableFlakes = true; }; } )
|
||||||
];
|
];
|
||||||
|
|
@ -164,7 +164,7 @@ or `~/.config/direnv/direnvrc`:
|
||||||
source $HOME/nix-direnv/direnvrc
|
source $HOME/nix-direnv/direnvrc
|
||||||
```
|
```
|
||||||
|
|
||||||
You also need to set `keep-outputs` and `keep-derivations` to nix.conf
|
You also need to set `keep-outputs` and `keep-derivations` to nix.conf
|
||||||
as described in the installation via home-manager section.
|
as described in the installation via home-manager section.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
@ -208,7 +208,7 @@ The code is tested and does work but the upstream flake api is not finalized,
|
||||||
so we we cannot guarantee stability after an nix upgrade.
|
so we we cannot guarantee stability after an nix upgrade.
|
||||||
|
|
||||||
Like `use_nix`,
|
Like `use_nix`,
|
||||||
our `use_flake` will prevent garbage collection of downloaded packages,
|
our `use_flake` will prevent garbage collection of downloaded packages,
|
||||||
including flake inputs.
|
including flake inputs.
|
||||||
|
|
||||||
### Creating a new flake-native project
|
### Creating a new flake-native project
|
||||||
|
|
@ -264,7 +264,7 @@ Due to historical reasons, the argument parsing emulates `nix shell`.
|
||||||
|
|
||||||
This leads to some limitations in what we can reasonably parse.
|
This leads to some limitations in what we can reasonably parse.
|
||||||
|
|
||||||
Currently, all single-word arguments and some well-known double arguments
|
Currently, all single-word arguments and some well-known double arguments
|
||||||
will be interpeted or passed along.
|
will be interpeted or passed along.
|
||||||
|
|
||||||
##### Known arguments
|
##### Known arguments
|
||||||
|
|
@ -275,18 +275,48 @@ will be interpeted or passed along.
|
||||||
|
|
||||||
`--command`, `--run`, `--exclude`, `--pure`, `-i`, and `--keep` are explicitly ignored.
|
`--command`, `--run`, `--exclude`, `--pure`, `-i`, and `--keep` are explicitly ignored.
|
||||||
|
|
||||||
All single word arguments (`-j4`, `--impure` etc)
|
All single word arguments (`-j4`, `--impure` etc)
|
||||||
are passed to the underlying nix invocation.
|
are passed to the underlying nix invocation.
|
||||||
|
|
||||||
##### Tracked files
|
#### Tracked files
|
||||||
|
|
||||||
`nix-direnv` makes a performance tradeoff only considers changes in a limited
|
`nix-direnv` makes a performance tradeoff
|
||||||
number of files when deciding to update its cache.
|
and only considers changes in a limited number of files
|
||||||
|
when deciding to update its cache.
|
||||||
|
|
||||||
- for `use nix` this is `~/.direnvrc`, `~/.config/direnv/direnvrc`, `.envrc`, `default.nix` and `shell.nix`
|
- for `use nix` this is:
|
||||||
- for `use flake` this is `~/.direnvrc`, `~/.config/direnv/direnvrc`, `.envrc`, `flake.nix`, `flake.lock` and `devshell.toml`
|
* `~/.direnvrc`
|
||||||
|
* `~/.config/direnv/direnvrc`
|
||||||
|
* `.envrc`,
|
||||||
|
* A single nix file. In order of preference:
|
||||||
|
+ The file argument to `use nix`
|
||||||
|
+ `default.nix` if it exists
|
||||||
|
+ `shell.nix` if it exists
|
||||||
|
|
||||||
To add more files to be checked use `nix_direnv_watch_file` like this: `nix_direnv_watch_file your-file.nix`
|
- for `use flake` this is:
|
||||||
|
* `~/.direnvrc`
|
||||||
|
* `~/.config/direnv/direnvrc`
|
||||||
|
* `.envrc`
|
||||||
|
* `flake.nix`
|
||||||
|
* `flake.lock`
|
||||||
|
* `devshell.toml` if it exists
|
||||||
|
|
||||||
|
To add more files to be checked use `nix_direnv_watch_file` like this
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ nix_direnv_watch_file your-file.nix
|
||||||
|
```
|
||||||
|
|
||||||
|
Or - if you don't mind the overhead (runtime and conceptual) of watching all nix-files:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix_direnv_watch_file $(find . -name "*.nix" -printf '"%p" ')
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this will re-execute direnv for any nix change,
|
||||||
|
regardless of whether that change is meaningful for the devShell in use.
|
||||||
|
|
||||||
|
`nix_direnv_watch_file` must be invoked before either `use flake` or `use nix` to take effect.
|
||||||
|
|
||||||
## General direnv tips
|
## General direnv tips
|
||||||
|
|
||||||
|
|
|
||||||
2
direnvrc
2
direnvrc
|
|
@ -303,7 +303,7 @@ use_nix() {
|
||||||
done
|
done
|
||||||
|
|
||||||
# nixfile may be empty,
|
# nixfile may be empty,
|
||||||
# but nix_direnv_watch_file checks for existance before adding to watches
|
# but nix_direnv_watch_file checks for existence before adding to watches
|
||||||
nix_direnv_watch_file "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc" .envrc "$nixfile"
|
nix_direnv_watch_file "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc" .envrc "$nixfile"
|
||||||
|
|
||||||
local need_update=0
|
local need_update=0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue