fix(nix): normalize after all bootstrap writes

This commit is contained in:
Phoebus 2026-09-28 06:25:09 -07:00
parent 030e87edf5
commit bc0c4b8b2c

View file

@ -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"));