Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 61f12eb907f3
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cb007e69a140
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jan 15, 2020

  1. stdenv: make symlinks that refer to the same output relative

    While looking at the graph of all the outputs in my personal binary
    cache it became obvious that we have a lot of self references within the
    package set. That isn't an isuse by itself. However it increases the
    size of the binary cache for every (reproducible) build of a package
    that carries references to itself. You can no longer deduplicate the
    outputs since they are all unique. One of the ways to get rid of (a few)
    references is to rewrite all the symlinks that are currently used to be
    relative symlinks. Two build of something that didn't really change but
    carries a self-reference can the be store as the same NAR file again.
    
    I quickly hacked together this change to see if that would yield and
    success. My bash scripting skills are probably not great but so far it
    seem to somewhat work.
    andir authored and FRidh committed Jan 15, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    tadeokondrak Tadeo Kondrak
    Copy the full SHA
    cb007e6 View commit details
Showing with 29 additions and 0 deletions.
  1. +28 −0 pkgs/build-support/setup-hooks/make-symlinks-relative.sh
  2. +1 −0 pkgs/stdenv/generic/default.nix
28 changes: 28 additions & 0 deletions pkgs/build-support/setup-hooks/make-symlinks-relative.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
fixupOutputHooks+=(_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)
}
1 change: 1 addition & 0 deletions pkgs/stdenv/generic/default.nix
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ let lib = import ../../../lib; in lib.makeOverridable (
let
defaultNativeBuildInputs = extraNativeBuildInputs ++
[ ../../build-support/setup-hooks/move-docs.sh
../../build-support/setup-hooks/make-symlinks-relative.sh
../../build-support/setup-hooks/compress-man-pages.sh
../../build-support/setup-hooks/strip.sh
../../build-support/setup-hooks/patch-shebangs.sh