mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 10:53:11 +00:00
6c01681679
wlroots(and others) have ``` wlroots> +++ find /nix/store/3a0xwszw8n5dzzhsgfnilvsqi4hk565s-wlroots-0.15.1-examples -type l -print0 wlroots> find: '/nix/store/3a0xwszw8n5dzzhsgfnilvsqi4hk565s-wlroots-0.15.1-examples': No such file or directory ``` because the examples output is created in postFixup while this hook runs in fixupPhase
29 lines
894 B
Bash
29 lines
894 B
Bash
postFixupHooks+=(_makeSymlinksRelative)
|
|
|
|
# For every symlink in $output that refers to another file in $output
|
|
# ensure that the symlink is relative. This removes references to the output
|
|
# has from the resulting store paths and thus the NAR files.
|
|
_makeSymlinksRelative() {
|
|
local symlinkTarget
|
|
|
|
if [ -n "${dontRewriteSymlinks-}" ]; then
|
|
return 0
|
|
fi
|
|
|
|
while IFS= read -r -d $'\0' f; do
|
|
symlinkTarget=$(readlink "$f")
|
|
if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then
|
|
# skip this symlink as it doesn't point to $prefix
|
|
continue
|
|
fi
|
|
|
|
if [ ! -e "$symlinkTarget" ]; then
|
|
echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"
|
|
fi
|
|
|
|
echo "rewriting symlink $f to be relative to $prefix"
|
|
ln -snrf "$symlinkTarget" "$f"
|
|
|
|
done < <(find $prefix -type l -print0)
|
|
}
|