Skip to content

Commit 57687fc

Browse files
committed
feat: handling symlinks
1 parent 5eb9ef5 commit 57687fc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

nix/ext/pg_cron.nix

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,24 @@ stdenv.mkDerivation {
117117
NIX_PROFILE="/var/lib/postgresql/.nix-profile"
118118
119119
# Follow the complete chain of symlinks to find the multi-version directory
120-
CURRENT_LINK="$NIX_PROFILE/lib/pg_cron-$VERSION.so"
120+
CURRENT_LINK="$NIX_PROFILE/lib/pg_cron-$VERSION${postgresql.dlSuffix}"
121121
echo "Starting with link: $CURRENT_LINK"
122122
123-
while [ -L "$CURRENT_LINK" ]; do
124-
NEXT_LINK=$(readlink "$CURRENT_LINK")
125-
echo "Following link: $NEXT_LINK"
126-
if echo "$NEXT_LINK" | grep -q '^/'; then
127-
CURRENT_LINK="$NEXT_LINK"
128-
else
129-
CURRENT_LINK="$(dirname "$CURRENT_LINK")/$NEXT_LINK"
123+
# Follow first two symlinks to get to the multi-version directory
124+
for i in 1 2; do
125+
if [ -L "$CURRENT_LINK" ]; then
126+
NEXT_LINK=$(readlink "$CURRENT_LINK")
127+
echo "Following link: $NEXT_LINK"
128+
if echo "$NEXT_LINK" | grep -q '^/'; then
129+
CURRENT_LINK="$NEXT_LINK"
130+
else
131+
CURRENT_LINK="$(dirname "$CURRENT_LINK")/$NEXT_LINK"
132+
fi
133+
echo "Current link is now: $CURRENT_LINK"
130134
fi
131-
echo "Current link is now: $CURRENT_LINK"
132135
done
133136
134-
# The final link should be in the multi-version directory
137+
# The multi-version directory should be the parent of the current link
135138
MULTI_VERSION_DIR=$(dirname "$CURRENT_LINK")
136139
echo "Found multi-version directory: $MULTI_VERSION_DIR"
137140
LIB_DIR="$MULTI_VERSION_DIR"

0 commit comments

Comments
 (0)