Why is automatic chroot store only available on linux and not MacOS?
Is your feature request related to a problem? Please describe.
I'd like to use Nix without /nix on MacOS as it's a major pain to create it.
I saw this recent patch that makes nix use a chroot store automatically if /nix doesn't exist. This sounds like exactly what I want!
https://github.com/NixOS/nix/blob/04e74f7c8bb5589dec578dd049013d3cd2554e65/src/libstore/store-api.cc#L1349-L1373
but it's #if __linux__'d. I was wondering why? as MacOS has chroot() support AFAIk and nix build --store ./my-store seems to work fine on MacOS
Describe the solution you'd like
Remove the #if __linux__.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
This condition was added in https://github.com/NixOS/nix/pull/6714/commits/30d4aa5dd651813578b67d70ffbcd0446f6f0fe7 but it doesn't explain why it would only work on linux. In my mind this should work fine on MacOS
as MacOS has chroot() support AFAIk and nix build --store ./my-store seems to work fine on MacOS
I might be mistaken (I don't really know MacOS and I don't have a Mac without Nix to try), but I think this won't work if /nix doesn't exist. AFAIU it's because although chroot exists OSX doesn't have mount namespaces or bind-mounting, so the sandbox is implemented using a totally different mechanism (sandbox-exec) which just allows filtering which paths are visible, but not remap them. Meaning that Nix can't fake a /nix directory like it does on Linux
I'd like to use Nix without
/nixon MacOS as it's a major pain to create it.
Not to sidetrack this, but what about creating /nix isn't working? (AFAIK the installer can handle this in most cases; the only asterisk I think I know about is macs that are enrolled in an MDM that uses a policy to keep them from mounting volumes at all?)