Open grahamc opened 7 months ago
I have the same problem and didn't get my /etc/zshenv
, /etc/zshrc
, /etc/nix/nix.config
restored.
During installation I got:
❯ nix run nix-darwin -- switch --flake ~/.config/nix-darwin
warning: creating lock file '/Users/nick/.config/nix-darwin/flake.lock':
• Added input 'nix-darwin':
'github:LnL7/nix-darwin/36524adc31566655f2f4d55ad6b875fb5c1a4083' (2024-03-30)
• Added input 'nix-darwin/nixpkgs':
follows 'nixpkgs'
• Added input 'nixpkgs':
'github:NixOS/nixpkgs/692ceb334b4fd60d61798dde895f6f122110f5fe' (2024-04-13)
building the system configuration...
Password:
setting up /run via /etc/synthetic.conf...
error: Unexpected files in /etc, aborting activation
The following files have unrecognized content and would be overwritten:
/etc/zshenv
Please check there is nothing critical in these files, rename them by adding .before-nix-darwin to the end, and then try again.
I moved /etc/zshenv
to /etc/zshen.before-nix-darwin
and then rerun installation:
❯ nix run nix-darwin -- switch --flake ~/.config/nix-darwin
building the system configuration...
user defaults...
setting up user launchd services...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
creating service org.nixos.activate-system
reloading service org.nixos.nix-daemon
reloading nix-daemon...
waiting for nix-daemon
waiting for nix-daemon
configuring networking...
setting nvram variables...
I checked those zsh* files and see that /etc/zshrc
got renamed to /etc/zshrc.before-nix-darwin
automatically.
After that I ran uninstall script:
❯ darwin-uninstaller
Uninstalling nix-darwin, this will:
- remove /Applications/Nix Apps symlink
- cleanup static /etc files
- disable and remove all launchd services managed by nix-darwin
- restore daemon service from nix installer (only when this is a multi-user install)
Proceed? [y/n] y
user defaults...
setting up user launchd services...
Password:
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
removing service org.nixos.activate-system
removing service org.nixos.nix-daemon
configuring networking...
setting nvram variables...
rm: cannot remove '/Library/LaunchDaemons/org.nixos.nix-daemon.plist': No such file or directory
grep: /etc/bashrc: No such file or directory
Found no nix-daemon.sh reference in /etc/bashrc
add this snippet back to /etc/bashrc:
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
NOTE: The /nix/var/nix/profiles/system* profiles still exist and won't be garbage collected.
Done!
*.before-nix-darwin
did not get restored and now the nix and other stuff gets broken.
I don't know if I have the right expectation though that it should restore those files automatically.
Also it renamed and then didn't restore /etc/nix/nix.config
which I caught by chance.
After installing and uninstalling nix-darwin today, it looks like nix-darwin removed the zshenv and the standard zshrc file from /etc, but then doesn't restore them:
which leaves the user in a semi-broken Nix and terminal state.