From bc0c4b8b2c252560cbdd8235479396e00cc9544f Mon Sep 17 00:00:00 2001 From: Phoebus Date: Mon, 28 Sep 2026 06:25:09 -0700 Subject: [PATCH] fix(nix): normalize after all bootstrap writes --- installer-rs/crates/phoebus-executor/src/nix.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/installer-rs/crates/phoebus-executor/src/nix.rs b/installer-rs/crates/phoebus-executor/src/nix.rs index e9885fb..eb070ad 100644 --- a/installer-rs/crates/phoebus-executor/src/nix.rs +++ b/installer-rs/crates/phoebus-executor/src/nix.rs @@ -188,11 +188,11 @@ fn bootstrap(exec: &Exec, root: &Path, tarball: &Path) -> Result<()> { // Every user must traverse the store and read profiles: the client // binary, the daemon socket and per-user generations all live under // /nix. Staging (`cp -a`) preserves tarball modes and the live shell's - // umask may be restrictive, so normalize the top-level integration - // directories explicitly (never the store contents themselves). Proven - // by VM boot: without this, `nix` is "command not found" for the user - // and `sys list --nix` reports Nix as not installed. - normalize_integration_permissions(root); + // umask may be restrictive, so the top-level integration paths are + // normalized at the END of the bootstrap (after every write below). + // Proven by VM boot: without this, `nix` is "command not found" for the + // user and `sys list --nix` reports Nix as not installed; /etc/nix and + // /etc/profile.d/nix.sh are unreadable for the same reason. { use std::os::unix::fs::PermissionsExt; let sock = target_path(root, "nix/var/nix/daemon-socket"); @@ -258,6 +258,9 @@ fn bootstrap(exec: &Exec, root: &Path, tarball: &Path) -> Result<()> { } let _ = crate::portage::chroot(exec, root, "systemctl", &["enable", "nix-daemon.service"]); let _ = crate::portage::chroot(exec, root, "systemctl", &["enable", "nix-daemon.socket"]); + // Normalize AFTER every write above: the config, profile links and unit + // symlinks did not exist when the state directories were created. + normalize_integration_permissions(root); exec.logger .info(format!("Nix {NIX_VERSION} bootstrapped into the target"));