Skip to content

Commit 945e6e6

Browse files
committed
Install Nix: add copyNix()
rm old message copying Nix rm old store fill-up
1 parent 07cf67a commit 945e6e6

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

scripts/install-nix-from-closure.sh

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -648,28 +648,39 @@ installNix() {
648648
}
649649
mkdir -p "$dest"/store
650650
}
651+
652+
copyNix() {
653+
print "Copying Nix to '$dest/store': "
654+
655+
for object in $(cd "$self/store" >/dev/null && echo ./*); do
656+
printf '.'
657+
get="$self/store/$object"
658+
tmp="$dest/store/$object.$$" ## $$ - is process PID
659+
put="$dest/store/$object"
660+
661+
# If $dest/store/$object.$$ exists - remove. Very certain - it is a directory from previous cycle.
662+
if [ -e "$tmp" ]; then
663+
rm -rf "$tmp"
664+
fi
665+
# If $put does not exist - populate it.
666+
if ! [ -e "$put" ]; then
667+
# Copy $get to $tmp
668+
cp -Rp "$get" "$tmp"
669+
# Remove write permissions from $tmp recursively
670+
chmod -R a-w "$tmp"
671+
# Place $tmp as $put
672+
mv "$tmp" "$put"
673+
else
674+
print "Already exists, skipping: '$put'"
675+
fi
676+
677+
done
678+
printf '\n'
679+
}
651680
}
652681

653682
}
654683
echo "performing a single-user installation of Nix..." >&2
655-
printf "copying Nix to %s..." "${dest}/store" >&2
656-
657-
for i in $(cd "$self/store" >/dev/null && echo ./*); do
658-
printf "." >&2
659-
i_tmp="$dest/store/$i.$$"
660-
if [ -e "$i_tmp" ]; then
661-
rm -rf "$i_tmp"
662-
fi
663-
if ! [ -e "$dest/store/$i" ]; then
664-
cp -Rp "$self/store/$i" "$i_tmp"
665-
chmod -R a-w "$i_tmp"
666-
chmod +w "$i_tmp"
667-
mv "$i_tmp" "$dest/store/$i"
668-
chmod -w "$dest/store/$i"
669-
fi
670-
done
671-
echo "" >&2
672-
673684
echo "initialising Nix database..." >&2
674685
if ! $nix/bin/nix-store --init; then
675686
echo "$0: failed to initialize the Nix database" >&2

0 commit comments

Comments
 (0)