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.
···1+# The program `remove-references-to' created by this derivation replaces all
2+# references to the given Nix store paths in the specified files by a
3+# non-existent path (/nix/store/eeee...). This is useful for getting rid of
4+# dependencies that you know are not actually needed at runtime.
5+6+{ stdenv, writeScriptBin }:
7+8+writeScriptBin "remove-references-to" ''
9+#! ${stdenv.shell} -e
10+11+# References to remove
12+targets=()
13+while getopts t: o; do
14+ case "$o" in
15+ t) storeId=$(echo "$OPTARG" | sed -n "s|^$NIX_STORE/\\([a-z0-9]\{32\}\\)-.*|\1|p")
16+ if [ -z "$storeId" ]; then
17+ echo "-t argument must be a Nix store path"
18+ exit 1
19+ fi
20+ targets+=("$storeId")
21+ esac
22+done
23+shift $(($OPTIND-1))
24+25+# Files to remove the references from
26+regions=()
27+for i in "$@"; do
28+ test ! -L "$i" -a -f "$i" && regions+=("$i")
29+done
30+31+for target in "''${targets[@]}" ; do
32+ sed -i -e "s|$NIX_STORE/$target-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" "''${regions[@]}"
33+done
34+''