2 improvements this Spring laid a foundation for big wins on ongoing pain points:
CI (GitHub Actions) for nixos/nix now generates full installers and runs installer tests for Ubuntu + macOS. You can trivially set this up to run on your fork.
(If the cumbersome process of manually testing changes taught you to avoid touching the installer, I suggest giving it a fresh look. It’s hard to overstate how much easier it is!)
In the course of #4289 darwin: encrypt nix volume if filevault is enabled, I developed some new patterns for ~curing inconsistent artifacts on macOS that can be re-used elsewhere.
I’ll save detail for a follow-up, but generally these light the path to:
- installer support for
--uninstall and reinstalling over existing installs
- expanding test coverage of different install scenarios
I need to focus on other projects for a while and won’t have time for these UX/DX investments for at least a few months, but I’m happy to help others get up to speed and provide feedback.
Can the full installers from (1) be fed to
install-nix-action the way numtide’s nix-unstable-installer is currently? (I ask because unstable has been rocky lately and constant new releases to update to would be helpful.)
I haven’t used the numtide installer, but AFAIK the answer is yes (this is how the tests work). The .yml may be a good resource for more detail:
Following up on what I think the projects/work here are. There are at least two (and maybe more) parts that can be separated if there are enough hands.
This is probably a single project.
I did a proof-of-concept towards this back in late October. It’d need some defrosting, but it may help get started. Here’s the commit where I removed that experiment from my WIP: drop uninstaller code for now · abathur/nix@630a91c · GitHub
It’ll be easier with access to Linux and macOS, but it may not be essential.
I think the bulk of the work should be semi-straightforwardly applying patterns from #4289 to individual artifacts and state changed by the installer.
Shooting from the hip, but AFAIR the patterns address:
- prompting the user (optionally with sudo/password for more-serious changes) for adding/removing something
- showing them the change as needed
- queuing reminders (next steps, notes, etc.) for presentation afterwards
- granular add/remove uses the same work to support both
--uninstall and reinstall (remove, add)
The “harder” problem (and the part that might be splittable?) will be figuring out what to do with/about the single-user install mode (and getting buy-in).
- I think this can wait until the features work in the multi-user installer and it’s possible to demo the experience.
- IIRC the outer installer targets posix sh, while the multi-user installer specifies bash.
This should be easier to split up into more work. (Update: I created a separate thread dedicated to this)
- There are many distinct cases wrt shells people use and what profile/rc files they have present.
- Ideally, the test should cover starting a new shell (without inheriting env) to verify that the shell startup is working correctly.
- This process may also help find conditions that the installer can be testing for and either curing or alerting the user about.
- Populating distinct test-cases should be a fairly shovel-ready contribution to clarifying what does/doesn’t work and avoiding regressions. Issues filed against Nix may be a good resource for detail.
- Install tests currently use install-nix-action, which IIRC limits it to multi-user installs. In order to add single-user test cases, we may need some support in install-nix-action, or a replacement mechanism dedicated to testing?
- The --uninstall/reinstall work above should be able to build on top of the distinct shell/setup cases. There may be some prep work WRT to being able to validate the result of removal/reinstall.
I took a little time to find some summary of the proof-of-concept I mentioned before. I think the removal commit may be the most-cohesive single reference: drop uninstaller code for now · abathur/nix@630a91c · GitHub
(apologies if you follow many issues below and got thoroughly spammed by this)
To help cross-link and in case I get hit by the proverbial bus, here are some notes I compiled during #4289 of issues open at that time which I believe the project(s) described here can close:
- uninstaller/reinstall FRs
- documentation requests
Nix PR #3788 extended the install script to cater for distros with non-systemd init systems, so it may be prudent to add uninstall instructions for it.
(To be fair, some steps seem to have been left as an exercise for the users in this case, so the uninstall steps would be wildly different depending on the init system and user preferences… Anyway, only wanted to leave this here for completeness sake.)
I recently had to uninstall and reinstall Nix on my m1 mac. It took me quite some time, but this is everything I needed to get it removed and reinstalled.
Delete Nix Store from disk utility
Remove /nix entry from /etc/fstab (possibly optional) with
sudo nano /etc/fstab
sudo rm -rf /etc/synthetic.conf
sudo dscl . -list /Users | grep nix | xargs -I % sudo dscl . -delete /Users/%
sudo dscl . -delete /Groups/nixbld
sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
sudo mv /etc/bash.bashrc.backup-before-nix /etc/bash.bashrc
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
sudo rm -rf /etc/nix /nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels /Users/alishataylor/.nix-profile /Users/alishataylor/.nix-defexpr /Users/alishataylor/.nix-channels
sudo launchctl enable system/org.nixos.nix-daemon
sh <(curl -L https://nixos.org/nix/install) --daemon --darwin-use-unencrypted-nix-store-volume
These are some the threads I worked through as I hit each error:
- Unable to install Nix 2.4 and 2.5.1 on Mac OS Monterey · Issue #5498 · NixOS/nix · GitHub
- Installing nix on macOS BigSur · GitHub
- Multi-user installation fails on macOS Mojave · Issue #4020 · NixOS/nix · GitHub
- I can't install Nix on macOS Catalina with multi-user · Issue #4106 · NixOS/nix · GitHub
- Multi-user Darwin installer fails to load org.nixos.nix-daemon · Issue #2780 · NixOS/nix · GitHub
To add some background, I had Nix multi-user on my machine, but a tutorial had me install the single user version as a requirement to continue. I then realized that I need the multi-user for work, so needed to add it back but hit a ton of issues, including some of the errors below:
error: the build users group 'nixbld' has no members
Could not find service "org.nixos.nix-daemon" in domain for system
org.nixos.nix-daemon.plist: Service is disabled
Hope this helps someone one day, maybe even future me!
EDIT - Check out the installation manual that toonn linked below, which solves every single issue here!
cc @toonn, this would be nice to cover as part of Nix 🖤 macOS - Open Collective
@atayl16, I wonder how the instructions that have made it into the Nix manual (only somewhat recently) fell short? Or was the problem even finding out about their existence?
That’s it exactly. I was given a command to install Nix via command line, so when I hit errors, I googled them. A link in the installer about where to learn more would have saved me a ton of time. I had no idea this page existed
I’m tempted to go to all of those links and add your link back to the manual for everyone that searches later!
FWIW, I’m a new user who needed to uninstall Nix on my Mac M1. Followed the instructions multiple times, but was met with the same error each time trying to reinstall.
The instructions above from @ atayl16 worked perfectly. Not sure what the diff is between the two versions — just wanted to relay my experience. Thanks!
Could you tell us exactly what went wrong when following the uninstall instructions? If you read atayl16’s post carefully you’ll see that both of us believe the current uninstall instructions cover everything they did manually.
If the instructions are insufficient I’d like to fix that but I don’t know what the crucial difference is.