1 # symlinks are often created in postFixup
2 # don't use fixupOutputHooks, it is before postFixup
3 postFixupHooks
+=(_makeSymlinksRelativeInAllOutputs
)
5 # For every symlink in $output that refers to another file in $output
6 # ensure that the symlink is relative. This removes references to the output
7 # has from the resulting store paths and thus the NAR files.
8 _makeSymlinksRelative
() {
11 if [ "${dontRewriteSymlinks-}" ] ||
[ ! -e "$prefix" ]; then
15 while IFS
= read -r -d $
'\0' f
; do
16 symlinkTarget
=$
(readlink
"$f")
17 if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then
18 # skip this symlink as it doesn't point to $prefix
22 if [ ! -e "$symlinkTarget" ]; then
23 echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"
26 echo "rewriting symlink $f to be relative to $prefix"
27 ln -snrf "$symlinkTarget" "$f"
29 done < <(find $prefix -type l
-print0)
32 _makeSymlinksRelativeInAllOutputs
() {
34 for output
in $
(getAllOutputNames
); do
35 prefix
="${!output}" _makeSymlinksRelative