nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 37 lines 1.2 kB view raw
1# symlinks are often created in postFixup 2# don't use fixupOutputHooks, it is before postFixup 3postFixupHooks+=(_makeSymlinksRelativeInAllOutputs) 4 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() { 9 local symlinkTarget 10 11 if [ "${dontRewriteSymlinks-}" ] || [ ! -e "$prefix" ]; then 12 return 13 fi 14 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 19 continue 20 fi 21 22 if [ ! -e "$symlinkTarget" ]; then 23 echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)" 24 fi 25 26 echo "rewriting symlink $f to be relative to $prefix" 27 ln -snrf "$symlinkTarget" "$f" 28 29 done < <(find $prefix -type l -print0) 30} 31 32_makeSymlinksRelativeInAllOutputs() { 33 local output 34 for output in $(getAllOutputNames); do 35 prefix="${!output}" _makeSymlinksRelative 36 done 37}