Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: experimental Nix feature 'auto-allocate-uids' is disabled; use '--extra-experimental-features auto-allocate-uids' to override #860

Closed
jongschneider opened this issue Feb 23, 2024 · 4 comments
Labels
MacOS Darwin/MacOS

Comments

@jongschneider
Copy link

I’ve been using nix with nix-darwin to manage my Mac system for the past month.

My setup is as follows:
macOS Sonoma version 14.3.1
Nix downloaded using The Determinate Nix Installer
Nix Installer Version: nix-installer 0.14.0
architecture: aarch64-darwin
Nix-Darwin downloaded using Flake installation.


Last night I was browsing github and looking at various darwin nix configurations and came across this repo that sets

extraOptions = ''
  extra-nix-path = nixpkgs=flake:nixpkgs
  auto-allocate-uids = true             <--- the big problem!!!
  build-users-group = nixbld
  experimental-features = nix-command flakes auto-allocate-uids
'';

Ever since I added this extraOption and rebuilt my system using darwin-rebuild switch --flake ~/PATH/TO/MY-NIX-DARWIN-CONFIG/ I can no longer do anything using the nix cli.

❯ darwin-rebuild switch --flake ~/PATH/TO/MY-NIX-DARWIN-CONFIG/
building the system configuration...
error: experimental Nix feature 'auto-allocate-uids' is disabled; use '--extra-experimental-features auto-allocate-uids' to override
❯ nix develop
error: experimental Nix feature 'auto-allocate-uids' is disabled; use '--extra-experimental-features auto-allocate-uids' to override

I found this github PR related to the experimental feature auto-uid-allocation which states:

No, this will never work on macOS since it requires cgroups.

My current state is that the programs I’ve previously installed work. But I cannot update my computer using nix in any way - no new programs, no flake updates, no darwin configuration changes, etc. So my laptop is not bricked. It just is in stasis and I need to use conventional package management for my applications. And dev environments no longer work (rip nix develop).

So now I’m wondering what are my options?
Here are some things I’ve tried that have not worked:

  • I removed auto-allocate-uids = true from my config.
  • I tried passing --extra-experimental-features auto-allocate-uids flag with my nix commands.
  • I tried uninstalling nix using /nix/nix-installer uninstall to start from scratch and reinstall I get:
❯ /nix/nix-installer uninstall
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
`nix-darwin` installation detected, it must be removed before uninstalling Nix. Please refer to https://github.com/LnL7/nix-darwin#uninstalling for instructions how to uninstall `nix-darwin`.
  • Even after having uninstalled nix-darwin using the nix-darwin uninstall script, I get the error above. I guess nix isn't recognizing that /run/current-system was deleted... That's basically all the nix-darwin uninstall script does.
  • I looked through the uninstall rust code to determine the source of this error message and it looks like it's coming from here but I don't write rust and so my ability to debug the issue locally was pretty much a non-starter.
  • I tried manually updating my nix.conf file in the nix store where the current symlink of /etc/static/nix/nix.conf points to. After it didn't solve the problem, I put it back to how it was before...

Is there any way to get past this? Any help would be greatly appreciated. I really love nix and am devastated that I broke it.

@cole-h
Copy link
Member

cole-h commented Feb 23, 2024

You should be able to do something like this:

$ cp /etc/nix/nix.conf /etc/nix/nix.conf.bak # copy the contents to a file nearby
$ unlink /etc/nix/nix.conf # remove the reference to the file in the Nix store
$ mv /etc/nix/nix.conf.bak /etc/nix/nix.conf # move the old contents back to where Nix will find it
$ sudo nano /etc/nix/nix.conf # make any changes necessary (like removing the `auto-allocate-ids` setting)
$ echo "now do your nix things like rebuilding nix-darwin, which might complain about the nix.conf but otherwise should work

Basically what that does is makes it so you can modify /etc/nix/nix.conf by hand (which you otherwise can't because it's a symlink from the Nix store which is read-only), so that you can remove the broken settings.

Let me know if that doesn't work, and we can go from there!

@cole-h cole-h added the MacOS Darwin/MacOS label Feb 23, 2024
@jongschneider
Copy link
Author

@cole-h
Thanks for your quick reply.

I got similar advice over here and did the following to fix the issue:


For anyone in the future who borks their system in a similar fashion, the fix was:

  1. use ls -alh /etc/static/nix/nix.conf and follow the symlinks to find the source location of nix.conf in the nix store.
  2. update this file in the store by removing auto-allocate-uids = true if it's there (it's read only by default so you will have to adjust the privileges save your changes).
  3. restart the nix daemon
sudo launchctl stop org.nixos.nix-daemon
sudo launchctl start org.nixos.nix-daemon

The big trick I was missing was manually restarting the nix daemon. It's all working now. Thanks a lot!

@cole-h
Copy link
Member

cole-h commented Feb 23, 2024

Ah, yep, I always forget about restarting the daemon too 😆 Glad you got it fixed!

@jeeftor
Copy link

jeeftor commented Apr 27, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MacOS Darwin/MacOS
Projects
None yet
Development

No branches or pull requests

3 participants