This allows for a less blanket approach than nuke-refs, targetting specific references that we know we don't want rather than all references that we don't know we want.
···11+# The program `remove-references-to' created by this derivation replaces all
22+# references to the given Nix store paths in the specified files by a
33+# non-existent path (/nix/store/eeee...). This is useful for getting rid of
44+# dependencies that you know are not actually needed at runtime.
55+66+{ stdenv, writeScriptBin }:
77+88+writeScriptBin "remove-references-to" ''
99+#! ${stdenv.shell} -e
1010+1111+# References to remove
1212+targets=()
1313+while getopts t: o; do
1414+ case "$o" in
1515+ t) storeId=$(echo "$OPTARG" | sed -n "s|^$NIX_STORE/\\([a-z0-9]\{32\}\\)-.*|\1|p")
1616+ if [ -z "$storeId" ]; then
1717+ echo "-t argument must be a Nix store path"
1818+ exit 1
1919+ fi
2020+ targets+=("$storeId")
2121+ esac
2222+done
2323+shift $(($OPTIND-1))
2424+2525+# Files to remove the references from
2626+regions=()
2727+for i in "$@"; do
2828+ test ! -L "$i" -a -f "$i" && regions+=("$i")
2929+done
3030+3131+for target in "''${targets[@]}" ; do
3232+ sed -i -e "s|$NIX_STORE/$target-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" "''${regions[@]}"
3333+done
3434+''