Pimp nixredo-gc to work around broken gcroots in local store
Add fake gcroots which have the right looks when running GC. Remove them after GC finished.master
parent
52f6a2badf
commit
034aa74e81
|
@ -1,4 +1,4 @@
|
|||
{ stdenv, jq }:
|
||||
{ stdenv, findutils, jq }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "nixredo-1";
|
||||
|
@ -8,6 +8,7 @@ stdenv.mkDerivation {
|
|||
libnix = ./lib.nix;
|
||||
|
||||
files = [ ./nixredo ./nixredo-deps ./nixredo-whichdo ./nixredo-gc ];
|
||||
find = "${findutils}/bin/find";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
|
21
nixredo-gc
21
nixredo-gc
|
@ -1,3 +1,24 @@
|
|||
#!/bin/sh
|
||||
[ "${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
|
||||
roots=
|
||||
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}"
|
||||
fi
|
||||
done
|
||||
|
||||
nix-store --store "${NIXREDO_ROOT}" --gc
|
||||
rm -rf -- "${NIXREDO_ROOT}/tmp"
|
||||
|
||||
for f in $roots; do
|
||||
rm -- "$f"
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue