etc: remove unneeded temporary directions after putting in place the new etc

This commit is contained in:
r-vdp 2024-09-05 15:28:00 +02:00
parent a2d4cea96e
commit 0f786baf5d
No known key found for this signature in database

View File

@ -276,6 +276,22 @@ in
# Unmount the top /etc mount to atomically reveal the new mount.
umount --lazy --recursive /etc
# Unmount the temporary mount
umount --lazy "$tmpEtcMount"
rmdir "$tmpEtcMount"
# Unmount old metadata mounts
# For some reason, `findmnt /tmp --submounts` does not show the nested
# mounts. So we'll just find all mounts of type erofs and filter on the
# name of the mountpoint.
findmnt --type erofs --list --kernel --output TARGET | while read -r mountPoint; do
if [[ "$mountPoint" =~ ^/tmp/nixos-etc-metadata\..{10}$ &&
"$mountPoint" != "$tmpMetadataMount" ]]; then
umount --lazy $mountPoint
rmdir "$mountPoint"
fi
done
fi
'' else ''
# Set up the statically computed bits of /etc.