Multiple versions of Nix installed as dependencies

Hello,
When I recently installed nixd as language server I noticed it pulls in Nix version 2.16 as a dependency, although the nix version on my system is 2.18. The nixpkgs version should be the same - unstable. So I went and checked the declaration in nixpkgs, but it does seem to use just the default Nix version.

Then I noticed that there is a third version installed on my system - Nix 2.15. This one is pulled in as a dependency of nixos-option. I don’t know what that package does, was not able to find documentation nor could I get it to print any useful information.

It would be nice to have packages use the same dependencies if possible. In this case I would really like to have nixd use the default Nix version, and either get rid of nixos-option or make it use the same version as well.

Do you maybe have a clue on how to fix this?

Nixd depends on nix 2.16 indeed: https://github.com/NixOS/nixpkgs/blob/102c34231850b2f18bc2eb295f2ff69b20d07c05/pkgs/top-level/all-packages.nix#L18376

I don’t think you can just change this, as nixd links to the nix C++ libraries and those libraries do not have a stable ABI between versions.

For nixos-option, I disabled this in my systems for the same reason, you can do so with

system.disableInstallerTools = true;

Be aware that this also disables things like nixos-rebuild, so I added that back manually to my system path, by doing

environment.systemPackages = [
  config.system.build.nixos-rebuild
];

I didn’t need any of the other installer tools, but you can add those back as well if you need them (things like nixos-install, nixos-generate-config, etc).

1 Like

Alright, thanks a lot!

You can have a look also at nil as a nix language server.

It doesn’t link to nix and so doesn’t depend on a specific version of nix.

It does not have exactly the same feature set though, it doesn’t do some of the things that nixd does (and maybe does some that nixd doesn’t), so up to you to decide which one suits your use case best.

Ok thanks for the hint. When I was looking for an language server I though linking against Nix was a good thing as it may ensure closer compatibility. But maybe I’ll try out nil as well. Are there any fundamental advantages/disadvantages to nil?