mirror of
https://github.com/nix-community/nix-direnv.git
synced 2024-09-19 07:17:10 +03:00
use_flake: add gcroot for inputs
This commit is contained in:
parent
24f58e2ed7
commit
e19d62fc02
@ -134,11 +134,13 @@ $ echo "use nix" >> .envrc
|
||||
$ direnv allow
|
||||
```
|
||||
|
||||
## Experimental flakes support
|
||||
## Flakes support
|
||||
|
||||
nix-direnv also comes with a flake alternative. The code is tested and works however
|
||||
since future nix versions might change their api regarding this feature we cannot
|
||||
guarantee stability after an nix upgrade.
|
||||
Likewise `use_nix` the `use_flake` implementation will prevent garbage
|
||||
collection of downloaded packages and also for flake inputs.
|
||||
|
||||
Save this file as `flake.nix`:
|
||||
|
||||
|
6
direnvrc
6
direnvrc
@ -55,6 +55,7 @@ use_flake() {
|
||||
watch_file flake.lock
|
||||
|
||||
local profile="$(direnv_layout_dir)/flake-profile"
|
||||
local flake="$(direnv_layout_dir)/flake"
|
||||
local profile_rc="${profile}.rc"
|
||||
|
||||
if [[ ! -e "$profile"
|
||||
@ -72,6 +73,11 @@ use_flake() {
|
||||
echo "$tmp_profile_rc" > "$profile_rc"
|
||||
rm -f "$tmp_profile" "$tmp_profile"*
|
||||
_nix_add_gcroot "$drv" "$profile"
|
||||
|
||||
# also add garbage collection root for source
|
||||
local flake_source=$(nix eval --impure --raw --expr 'builtins.getFlake (toString ./.)')
|
||||
_nix_add_gcroot "$flake_source" "$flake"
|
||||
|
||||
log_status renewed cache
|
||||
else
|
||||
log_status using cached dev shell
|
||||
|
Loading…
Reference in New Issue
Block a user