Skip to content

Commit 599411a

Browse files
committed
Refactor GC root refresh with array-based symlink handling
1 parent d43b745 commit 599411a

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

direnvrc

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,18 @@ _nix_refresh_gcroots() {
195195
local layout_dir
196196
layout_dir=$(direnv_layout_dir)
197197

198-
# Touch flake profile gcroot if it exists
199-
for profile_path in "${layout_dir}"/flake-profile*; do
200-
if [[ -L $profile_path ]]; then
201-
touch -h "$profile_path"
202-
fi
203-
done
204-
205-
# Touch flake inputs gcroots if they exist
206-
local flake_inputs
207-
flake_inputs="${layout_dir}/flake-inputs/"
208-
if [[ -d $flake_inputs ]]; then
209-
for input_path in "${flake_inputs}"/*; do
210-
if [[ -L $input_path ]]; then
211-
touch -h "$input_path"
212-
fi
213-
done
198+
local symlinks
199+
symlinks=(
200+
# Touch flake profile gcroot if it exists
201+
"${layout_dir}"/flake-profile-*
202+
# Touch flake inputs gcroots if they exist
203+
"${layout_dir}"/flake-inputs/*
204+
# Touch nix profile gcroot if it exists
205+
"${layout_dir}"/nix-profile-*
206+
)
207+
if ((${#symlinks[@]})); then
208+
touch -h "${symlinks[@]}"
214209
fi
215-
216-
# Touch nix profile gcroot if it exists
217-
for profile_path in "${layout_dir}"/nix-profile*; do
218-
if [[ -L $profile_path ]]; then
219-
touch -h "$profile_path"
220-
fi
221-
done
222210
}
223211

224212
_nix_clean_old_gcroots() {

0 commit comments

Comments
 (0)