From e99744f6289cd8c05067bf9a88e18f06190d7497 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 16 Sep 2026 12:00:13 -0400 Subject: [PATCH] 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. --- guest/common.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guest/common.nix b/guest/common.nix index 88423f2..853acdd 100644 --- a/guest/common.nix +++ b/guest/common.nix @@ -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 ''; };