Commit graph

149 commits

Author SHA1 Message Date
Arthur Noel
26d7044cd7 refactor logging
use functions wrapping direnv log_status and log_error
2023-11-29 13:28:03 +00:00
Jörg Thalheim
511f6554b3 bump version 2.5.1 2023-11-27 21:22:13 +01:00
Jörg Thalheim
a59d64917e do not deprecate nix_direnv_watch_file yet
we do this in 3.0.0
2023-11-27 20:19:21 +01:00
Arthur Noel
647d7feb7f _nix_direnv_watches: update path regex to match capitalized path 2023-11-26 21:06:37 +00:00
Jörg Thalheim
c84183c0ac bump version 2.5.0 2023-11-26 14:34:24 +01:00
mergify[bot]
c33cad83f8
Merge branch 'master' into no-grep 2023-11-26 13:29:01 +00:00
Jörg Thalheim
946b84daed fix crash if DIRENV_WATCHES is not set
This shouldn't happen in our current usage but better safe than sorry.
2023-11-26 14:19:24 +01:00
Jörg Thalheim
a20b32d9cd drop dependency on jq 2023-11-26 14:03:35 +01:00
Jörg Thalheim
4248f7735b use direnv show_dump to extract direnv watches 2023-11-26 13:15:37 +01:00
Jörg Thalheim
bcba9830e4 drop dependency on gnugrep 2023-11-26 12:32:12 +01:00
Arthur Noel
433948e9ad fix typos 2023-11-25 22:27:58 +00:00
Arthur Noel
6997988d1b drop nix_direnv_watch_file - instead parse DIRENV_WATCHES
fixes #408
2023-11-25 22:27:58 +00:00
Jörg Thalheim
da593f3b5e use_nix: watch for both shell.nix and default.nix
In many cases they will shell.nix will depend on default.nix and when a user switches from default.nix to shell.nix we also want to invalidate the cache.

fixes https://github.com/nix-community/nix-direnv/issues/409
2023-11-19 10:45:04 +01:00
Bryan Bennett
da6f18f71b
Quote layout_dir during script write
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-11-01 09:25:35 -04:00
Bryan Bennett
4bf5d40290
Fix local flakes when prefixed with "path:"
As mentioned in #347
2023-10-31 15:04:54 -04:00
Bryan Bennett
999093c7e6
Promote Out of date cache messages to error
This provides color so that the user can see them in the possible wall
of text that direnv sometimes spits out.
2023-10-31 15:04:51 -04:00
Bryan Bennett
f452533db5
Fix nix-direnv-reload
No longer assumes location of layout directory relative to code.
2023-10-31 15:04:43 -04:00
Nils
c61fca1ed0
Update nix-direnv version in nix_direnv_version 2023-10-23 11:46:14 -07:00
Jörg Thalheim
ac9cd95422 fix _nix_direnv_force_reload not beeing bound
fixes https://github.com/nix-community/nix-direnv/issues/393
2023-10-09 13:46:55 +02:00
cydparser
fc4fdbebf1 Simplify use_flake check for flag first arguments 2023-08-07 23:51:01 -07:00
cydparser
aeade6d235 Warn when use flake receives a flag for the first argument 2023-08-07 23:50:10 -07:00
Andreas Pelme
6b5822b75b Fixes for PR review:
- Always create the nix-direnv-reload script
- Use 0/1 for booleans
- Avoid crashing when profile_rc does not exist
- Use better internal variable name for manual mode
- Make use_nix work
- Avoid unneccessary forks
- Fix shellcheck failures
- Update mtime on profile rc files to avoid confusion about if the files
  are up to date
- Add instructions to README.md
2023-07-04 19:50:31 +00:00
Andreas Pelme
1df80c4c3a Run direnv reload after nix reload. 2023-07-04 19:50:31 +00:00
Andreas Pelme
828334a1c7 Use "reload" instead of "refresh" and create a script to make the reload. 2023-07-04 19:50:31 +00:00
Andreas Pelme
406a39036f Allow manual refresh of nix environment.
Adding nix_direnv_manual_refresh to .envrc will avoid the automatic
update of the nix environment on changes and allow the user to issue a
command to update the nix environment explicitly.

Sometimes it takes a long time to rebuild the nix environment and it
happens in times. Switching branches in or rebasing can be painful since
nix will re-evaluate between nix file changes.

This blog post explains the problems with blocking the shell:
https://dev.to/allenap/some-direnv-best-practices-actually-just-one-4864

This is a first prototype, the UX can certainly be improved a bit.
2023-07-04 19:50:30 +00:00
Jörg Thalheim
2e583c8d42 bump version 2.3.0 2023-04-15 17:27:41 +02:00
Bryan Bennett
195959cda3
Merge pull request #329 from amarshall/fix-strict-env-use-nix
Fix use nix with no nixpkgs when strict_env
2023-04-14 08:32:05 -04:00
Andrew Marshall
49de6ab18f Use nix-store --add-root instead of hard-coding gcroot path
The per-user gcroot path has changed in Nix 2.14, so this is broken with
that. Regardless, this is preferable since it decouples from the Nix
implementation.
2023-04-13 21:08:29 -04:00
Andrew Marshall
9d57d29192 Do not unnecessarily remove indirect gcroot links
These are linked to the paths removed in $layout_dir. Since the links
are thus broken, Nix will take care of removing these during GC. This
avoids depending on where Nix stores gcroots in this fn (but not
everywhere in nix-direnv…yet).
2023-04-13 21:07:54 -04:00
Andrew Marshall
784c9656b0 Fix use nix with no nixpkgs when strict_env
strict_env basically does `set -e`, and this fails in that case. We
handle it failing in the `if` on the subsequent line.
2023-04-13 15:24:01 -04:00
Simon Plakolb
8d28c8f84e preflight: Report nix version if its test fails 2023-02-23 20:38:07 +01:00
Simon Plakolb
149b71860d preflight: Check nix version constraints directly 2023-02-23 20:38:06 +01:00
Andrew Marshall
e761ab128c Fix reading nixpkgs version without trailing newline
`read` fails if it encounters EOF before the delim, the `.version` file
does not always have a newline, so `read` fails in that case. If the
env has `set -e` then this will abort. So add a newline to the end
always. Doesn’t seem to matter if there is more than one.
2023-02-22 22:27:26 -05:00
Jörg Thalheim
9e73e3ad70 fix error message if flake-inputs directory already exists
This fixes a race condition for me where concurrent direnv shells
creating this directory at the same time.
2023-01-31 17:54:38 +01:00
Jörg Thalheim
deb67e437b bump version 2.2.1 2023-01-19 11:04:43 +01:00
Jörg Thalheim
28a0597659 graceful fallback if no nixpkgs is in NIX_PATH 2023-01-16 14:06:09 +01:00
Bryan Bennett
7af01eeb72
Check if "$nixfile" is a file before watching
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2022-12-07 08:04:17 -05:00
Bryan Bennett
0db25e4de9
Don't track $nixfile if it is empty 2022-12-06 15:55:11 -05:00
Martin Kühl
3488dafb56 ensure XDG_DATA_DIRS contains unique entries
after importing from the nix environment
we currently concatenate the new and old values of XDG_DATA_DIRS,
which means if the nix environment reused or recreated the old values
they are now present twice.
XDG_DATA_DIRS is specified to be a "set",
and some software (GNOME for example) assume that its entries are unique.

this change reconstructs XDG_DATA_DIRS
by looping over the new and old entries
and adding the new ones among them.
it normalizes the entries by removing trailing slashes
to make duplicate detection a bit easier.
2022-12-05 13:48:20 +01:00
Jörg Thalheim
5d735de138 bump version 2.2.0 2022-11-20 23:36:42 +01:00
Jörg Thalheim
68245858ae
Merge pull request #256 from nix-community/less-verbose
make gcroot cleanup less verbose
2022-11-15 17:25:39 +01:00
Jörg Thalheim
f7e8a139d8 make gcroot cleanup less verbose
If you have a few more flakes this will spam your screen with a lot of text.
2022-11-14 09:36:55 +01:00
aabccd021
c3ea50a6de fix(direnvrc): log when nix-shell not found 2022-11-09 16:59:10 +07:00
Quentin Aristote
64c2b7bff7 clean old gcroots: typo in removal of flake-inputs 2022-10-21 12:17:59 +02:00
Quentin Aristote
2b5045d6f3 have the flake_inputs/ directory be cleaned inside clean_old_gc_roots 2022-10-20 16:50:56 +02:00
Quentin Aristote
ffd6b93c10 clean old gcroots: correct prefix of flake profiles (flake-profile-* instead of nix-flake-profile*) 2022-10-20 15:23:17 +02:00
Quentin Aristote
7e76b2e10a remove old gcroots when the environment is updated 2022-10-19 16:54:12 +02:00
Jörg Thalheim
e37d0f5679
Merge pull request #225 from nix-community/perf-improvements
Perf improvements
2022-09-03 12:25:43 +01:00
Bryan Bennett
d93ad1d842
Disallow writing a lock file during flake archival 2022-08-27 06:52:57 -04:00
Bryan Bennett
b1b717221a
Clean up documentation for tracked files 2022-08-27 06:52:54 -04:00