about summary refs log tree commit diff
path: root/nixos/modules/system/etc
diff options
context:
space:
mode:
authornikstur <nikstur@outlook.com>2024-02-21 22:54:00 +0100
committernikstur <nikstur@outlook.com>2024-02-21 22:54:00 +0100
commit5df8caced44e1435cb9f05fa24e5235bb699e07c (patch)
treef71b3b85764248ef2a63ad7a021c7385e00e4b9f /nixos/modules/system/etc
parent1e1efbcf8c211b8a5f6019116da8aef597f58642 (diff)
nixos/etc: make re-mounting /etc overlay idempotent
Diffstat (limited to 'nixos/modules/system/etc')
-rw-r--r--nixos/modules/system/etc/etc.nix4
1 files changed, 3 insertions, 1 deletions
diff --git a/nixos/modules/system/etc/etc.nix b/nixos/modules/system/etc/etc.nix
index baf37ba6def34..9f735364196c6 100644
--- a/nixos/modules/system/etc/etc.nix
+++ b/nixos/modules/system/etc/etc.nix
@@ -238,7 +238,9 @@ in
       # this should not run because /etc is mounted via a systemd mount unit
       # instead. To a large extent this mimics what composefs does. Because
       # it's relatively simple, however, we avoid the composefs dependency.
-      if [[ ! $IN_NIXOS_SYSTEMD_STAGE1 ]]; then
+      # Since this script is not idempotent, it should not run when etc hasn't
+      # changed.
+      if [[ ! $IN_NIXOS_SYSTEMD_STAGE1 ]] && [[ "${config.system.build.etc}/etc" != "$(readlink -f /run/current-system/etc)" ]]; then
         echo "remounting /etc..."
 
         tmpMetadataMount=$(mktemp --directory)