Skip to content
German Lashevich edited this page Aug 6, 2024 · 3 revisions

Upgrading Nix

By default darwin systems manages the version of nix in which case it can be declared in configuration.nix. This will handle the daemon service as well as the client.

Note

make sure services.nix-daemon.enable matches the installation mode you used when using an existing configuration.

{
  nix.package = pkgs.nixVersions.git;
  # services.nix-daemon.enable = true;
}

Environment inconsistencies

However nix-darwin doesn't touch the existing user profile where nix was installed originally so it's possible for that to take precedence in certain cases. Other tools might change PATH or a different version of nix might be installed in your user profile. If the version of nix doesn't change as expected make sure PATH in your shell matches the value of environment.systemPath and check if nix isn't installed in other places that conflict.

$ darwin-option environment.systemPath
Value:
"$HOME/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"

$ nix doctor
Running checks against store uri: daemon
[FAIL] Multiple versions of nix found in PATH:
  /nix/store/d0hz9vb2qjzcfm1ij8y2g02yd1r4yajv-nix-2.3.7/bin
  /nix/store/dz434dmq9jbji1xvzvx63yx1ssfhbwd1-nix-2.4pre20201031_2f3d023/bin

[PASS] All profiles are gcroots.
[PASS] Client protocol matches store protocol.

In this case you might need to remove the current nix package or make sure whatever changes PATH is disabled.

$ nix-env -e nix

Using a profile

Alternatively it's also possible to keep using the version of nix that was installed originally, however that does mean your system isn't fully declarative anymore. This could lead to some inconsistencies so beware.

{
  nix.package = "/nix/var/nix/profiles/default";
}