You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
926 B

exec >&2
[ "${S+x}" = x ] || { printf "Set S to the root location of your source tree\n"; exit 127; }
[ "${NIXREDO_ROOT+x}" = x ] || { printf "$0 only runs for private a nix store. Set NIXREDO_ROOT to a non-empty value\n"; exit 127; }
# Work around broken GCROOT support in local stores
# Add a fake gcroot which points to /nix/store/... instead of <local/store>/nix/store
# Remove fake roots after gc
mkdir -p "${NIXREDO_ROOT}/nix/var/nix/gcroots/auto"
for f in $(find "$S" -path "${NIXREDO_ROOT}" -prune -o -type l -print) ; do
p=$(realpath "$f")
if [ "${p#${NIXREDO_ROOT}}" != "$p" ]; then
gcroot=$(mktemp -u -p "${NIXREDO_ROOT}/nix/var/nix/gcroots/auto")
ln -s "${p#${NIXREDO_ROOT}}" "$gcroot"
roots="${roots} ${gcroot}"
nix-store --store "${NIXREDO_ROOT}" --gc
rm -rf -- "${NIXREDO_ROOT}/tmp"
for f in $roots; do
rm -- "$f"