From 0f786baf5db22e7eaa0e356b9ad595d9ee000eeb Mon Sep 17 00:00:00 2001 From: r-vdp Date: Thu, 5 Sep 2024 15:28:00 +0200 Subject: [PATCH] etc: remove unneeded temporary directions after putting in place the new etc --- nixos/modules/system/etc/etc.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nixos/modules/system/etc/etc.nix b/nixos/modules/system/etc/etc.nix index 7547f4304709..e8eeae03a360 100644 --- a/nixos/modules/system/etc/etc.nix +++ b/nixos/modules/system/etc/etc.nix @@ -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.