mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-18 14:08:16 +01:00
Nix 2.35's root nix-env -- used by nixos-rebuild to set the system profile -- calls saveMountNamespace(), which opens /proc/self/ns/mnt before remounting the read-only /nix/store writable. Those magic links have no connected path, so AppArmor cannot match them against any rule and denies the open with EACCES even in complain mode. The private mount namespace is then never created and nixos-rebuild aborts with: cannot remount "/nix/store" writable: not in a private mount namespace Adding flags=(attach_disconnected) lets AppArmor re-root those paths on / so the existing `file /**` rule matches. This also fixes any other sudo'd tool that needs namespaces (unshare, nsenter, bwrap, ...). Rolling this out to a host that already has the old profile loaded needs one deploy with --no-reexec, so the current system's Nix performs nix-env --set instead of the new system's; after that generation is active, plain `just niri` works and the Nix version is never rolled back.