···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.
56-{ stdenv, writeScriptBin }:
78-writeScriptBin "remove-references-to" ''
9-#! ${stdenv.shell} -e
1011-# 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))
002425-# Files to remove the references from
26-regions=()
27-for i in "$@"; do
28- test ! -L "$i" -a -f "$i" && regions+=("$i")
29-done
3031-for target in "''${targets[@]}" ; do
32- sed -i -e "s|$NIX_STORE/$target-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" "''${regions[@]}"
33-done
34-''
···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.
56+{ lib, stdenvNoCC, signingUtils, shell ? stdenvNoCC.shell }:
78+let
9+ stdenv = stdenvNoCC;
1011+ darwinCodeSign = stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64;
12+in
13+14+stdenv.mkDerivation {
15+ name = "remove-references-to";
16+17+ dontUnpack = true;
18+ dontConfigure = true;
19+ dontBuild = true;
20+21+ installPhase = ''
22+ mkdir -p $out/bin
23+ substituteAll ${./remove-references-to.sh} $out/bin/remove-references-to
24+ chmod a+x $out/bin/remove-references-to
25+ '';
2627+ postFixup = lib.optionalString darwinCodeSign ''
28+ mkdir -p $out/nix-support
29+ substituteAll ${./darwin-sign-fixup.sh} $out/nix-support/setup-hooks.sh
30+ '';
03132+ inherit (builtins) storeDir;
33+ shell = lib.getBin shell + (shell.shellPath or "");
34+ signingUtils = if darwinCodeSign then signingUtils else null;
35+}
···1+#! @shell@ -e
2+3+fixupHooks=()
4+5+if [ -e @out@/nix-support/setup-hooks.sh ]; then
6+ source @out@/nix-support/setup-hooks.sh
7+fi
8+9+# References to remove
10+targets=()
11+while getopts t: o; do
12+ case "$o" in
13+ t) storeId=$(echo "$OPTARG" | sed -n "s|^@storeDir@/\\([a-z0-9]\{32\}\\)-.*|\1|p")
14+ if [ -z "$storeId" ]; then
15+ echo "-t argument must be a Nix store path"
16+ exit 1
17+ fi
18+ targets+=("$storeId")
19+ esac
20+done
21+shift $(($OPTIND-1))
22+23+# Files to remove the references from
24+regions=()
25+for i in "$@"; do
26+ test ! -L "$i" -a -f "$i" && regions+=("$i")
27+done
28+29+for target in "${targets[@]}" ; do
30+ sed -i -e "s|@storeDir@/$target-|@storeDir@/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" "${regions[@]}"
31+done
32+33+for region in "${regions[@]}"; do
34+ for hook in "${fixupHooks[@]}"; do
35+ eval "$hook" "$i"
36+ done
37+done