How to upgrade nix on macOS with home-manager

In home.nix. It’s not meant to be taken literally because I don’t know what other settings you may or may not set.

Take the settings inside the attrset the function returns and add them to your existing attrset. You could also take that as a file and add it to imports as a module, of course, but that’d be total overkill.

I suspect you may want to have a look at the basic nix tutorials, it’ll make understanding stuff here much easier:

I’m already familiar with module system and the language, at least beyond introductory tutorials.
My problem with this kind of situations is precisely how flexible and dynamic nix is, and the “convention over tools” that everything follows. Because of that, there are many nix snippets that lack the context I need to understand them. On top of that, my current Darwin nix configuration has grown a bit over my capacity to understand it.
I have things quite split, and I have modules that import modules and I don’t have access to the same variables everywhere.
My question is, how are you supposed to sync nix-darwin nix and home-manager nix? As far as I know, nix-darwin doesn’t manage the nix installation. I managed to have home-manager manage my nix from pigs, but I don’t understand the meaning of syncing that with nix Darwin

Ah, well, this thread is explicitly about:

Hence my assumption that that’s what you’re doing.

With that said, you don’t need to do anything with your setup. nix-darwin manages everything for you, since you install home-manager as a nix-darwin module you don’t need to install home-manager or nix separately. nix-darwin will update your nix installation the same way it updates any other software installed through it.

Assuming you don’t disable the option that makes it do that of course.

If you have more questions, I’d encourage opening a new thread, maybe including the fact that you’re asking about nix-darwin explicitly.

Ah, my bad. I was quite tired yesterday and I think my brain assumed this was nix-darwin, sorry about that.

But nix-darwin requires you to install nix beforehand, so they don’t install nix. Also, in their more recent docs (what you linked) they say this:

You will also have to upgrade Nix yourself, as nix-darwin will no longer do so.

So I don’t understand what is they mean by “managing” if they don’t install it nor update it.

The thing is that having it as a package in home-manager has updated it to whatever is in nixpkgs, so I’m happy with the current outcome.
In any case, thank you very much, and sorry for using the thread in the wrong way

Yeah, because you need nix to build the nix-darwin activation script. Once you run that script it can install new versions of nix over what is installed, which you do every time you switch your config.

Maybe the docs are a bit unclear, that sentence is supposed to apply if you disable that option, which is enabled by default.

The readme does also state that using detsys nix is problematic for this, since the detsys installer is supposed to be used to update it. I’d recommend switching to nix (or lix) if you fell for that.

I would still recommend getting nix-darwin to work properly. By using home-manager for this you’re bypassing the nix-darwin modules and that may cause issues - this way nix-darwin can’t see what nix package is being used.

This is now squarely in nix-darwin support land, which I do not use, I think I’ll resist replying in this thread if you need more help :wink:

1 Like