guest: rm -rf /etc/nixos before symlinking it to the state disk

/etc/nixos is a real directory by default on NixOS. ln -sfn only replaces
an existing LINKNAME in place when it's already a symlink; against a plain
directory it instead creates the link *inside* it, leaving /etc/nixos
itself untouched. Confirmed live: /etc/nixos/nixos -> /var/lib/hermes/nixos
existed while /etc/nixos itself stayed a stray empty directory, so
`nix flake lock /etc/nixos` couldn't find a flake.nix. rm -rf first makes
this idempotent regardless of what currently occupies the path.
This commit is contained in:
ari committed 2026-09-16 12:00:13 -04:00
1 parent 55467ba8bf
commit e99744f628
1 file changed
+8
+8
View File
@@ -121,6 +121,14 @@ in
# /etc/nixos points at the state disk, so the config is snapshotted and
# backed up along with everything else the agent owns.
#
# /etc/nixos is a real directory by default on NixOS, not a symlink or
# missing path - `ln -sfn` only replaces an existing LINKNAME in place
# if it's already a symlink; against a plain directory it instead
# creates the link *inside* it (`/etc/nixos/nixos -> ...`), leaving
# /etc/nixos itself untouched. rm -rf first so this is idempotent
# either way.
rm -rf /etc/nixos
ln -sfn ${stateDir}/nixos /etc/nixos
'';
};