mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
Reimplement default watches with nix_direnv_watch_file
This commit is contained in:
parent
b52b067fa6
commit
bca290c875
1 changed files with 9 additions and 21 deletions
30
direnvrc
30
direnvrc
|
|
@ -140,8 +140,12 @@ _nix_argsum_suffix() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_direnv_watch_file() {
|
nix_direnv_watch_file() {
|
||||||
watch_file "$@"
|
for watch in "$@"; do
|
||||||
nix_watches+=("$@")
|
if [[ -e "${watch}" ]]; then
|
||||||
|
watch_file "${watch}"
|
||||||
|
nix_watches+=("${watch}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
use_flake() {
|
use_flake() {
|
||||||
|
|
@ -150,14 +154,9 @@ use_flake() {
|
||||||
flake_expr="${1:-.}"
|
flake_expr="${1:-.}"
|
||||||
flake_dir="${flake_expr%#*}"
|
flake_dir="${flake_expr%#*}"
|
||||||
|
|
||||||
nix_direnv_watch_file .envrc
|
nix_direnv_watch_file ".envrc" "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc"
|
||||||
if [[ -d "$flake_dir" ]]; then
|
if [[ -d "$flake_dir" ]]; then
|
||||||
nix_direnv_watch_file "$flake_dir/"flake.nix
|
nix_direnv_watch_file "$flake_dir/flake.nix" "$flake_dir/flake.lock" "$flake_dir/devshell.toml"
|
||||||
nix_direnv_watch_file "$flake_dir/"flake.lock
|
|
||||||
|
|
||||||
if [[ -e "$flake_dir/"devshell.toml ]]; then
|
|
||||||
nix_direnv_watch_file "$flake_dir/"devshell.toml
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local layout_dir profile
|
local layout_dir profile
|
||||||
|
|
@ -166,10 +165,6 @@ use_flake() {
|
||||||
local profile_rc="${profile}.rc"
|
local profile_rc="${profile}.rc"
|
||||||
local flake_inputs="${layout_dir}/flake-inputs/"
|
local flake_inputs="${layout_dir}/flake-inputs/"
|
||||||
|
|
||||||
nix_watches+=(
|
|
||||||
"$HOME/".direnvrc
|
|
||||||
)
|
|
||||||
|
|
||||||
local need_update=0
|
local need_update=0
|
||||||
local file=
|
local file=
|
||||||
for file in "${nix_watches[@]}"; do
|
for file in "${nix_watches[@]}"; do
|
||||||
|
|
@ -299,13 +294,7 @@ use_nix() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO: reimplement this in terms of `nix_direnv_watch_file`
|
nix_direnv_watch_file "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc" .envrc default.nix shell.nix
|
||||||
nix_watches+=(
|
|
||||||
"$HOME/".direnvrc
|
|
||||||
.envrc
|
|
||||||
default.nix
|
|
||||||
shell.nix
|
|
||||||
)
|
|
||||||
|
|
||||||
local need_update=0
|
local need_update=0
|
||||||
local file=
|
local file=
|
||||||
|
|
@ -365,7 +354,6 @@ use_nix() {
|
||||||
_nix_import_env "$profile_rc"
|
_nix_import_env "$profile_rc"
|
||||||
|
|
||||||
|
|
||||||
# TODO: Reimplement this in terms of `nix_direnv_watch_file`
|
|
||||||
if [[ "$#" == 0 ]]; then
|
if [[ "$#" == 0 ]]; then
|
||||||
watch_file default.nix
|
watch_file default.nix
|
||||||
watch_file shell.nix
|
watch_file shell.nix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue