From 48865a4aa61fb2901a173463d64ee05533af119c Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Sat, 26 Sep 2009 23:33:11 +0000 Subject: [PATCH] symlink duplicate git executables to bring down $out to 13MB (was > 100MB) svn path=/nixpkgs/trunk/; revision=17458 --- .../git-and-tools/git/default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkgs/applications/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix index 6a2393f3949..b94868b1471 100644 --- a/pkgs/applications/version-management/git-and-tools/git/default.nix +++ b/pkgs/applications/version-management/git-and-tools/git/default.nix @@ -87,6 +87,23 @@ stdenv.mkDerivation rec { + ''# install bash completion script d="$out/etc/bash_completion.d" ensureDir $d; cp contrib/completion/git-completion.bash "$d" + '' + # Don't know why hardlinks aren't created. git installs the same executable multiple times into $out + # so replace duplicates by symlinks because I haven't tested whether the nix + # distribution system can handle hardlinks. This reduces the size of $out from 115MB down to 13MB on x86_64-linux! + + ''# + set -x + declare -A seen + find $out -type f | while read f; do + sum=$(md5sum "$f"); + sum=''\${sum/ */} + if [ -z "''\${seen["$sum"]}" ]; then + seen["$sum"]="$f" + else + rm "$f"; ln -s "''\${seen["$sum"]}" "$f" + fi + done + ''; meta = {