How to get a newer version of the nix commands (in a flake devShell)

Recently a commit has been merged which improves quote handling the NIX_SSHOPTS variable used in the nix commands, i.e. nixos-rebuild, nix-copy-closure, etc.

It is available in Release 2.26 nix/doc/manual/source/release-notes/rl-2.26.md at 75db01c6f54ba14c36b1c549ba0d58c1ebc64f96 · NixOS/nix · GitHub

Unfortunately the latest release of nixos (24.11) still contains version 2.24.12 of the nix commands.

Is it somehow possible to the newer version of all commands provided by the nix package in a flake devShell, so that I can try out the changes made in this commit?
Or if that is not possible, can I change out the nix commands in my entire system for those from version 2.26 without having to upgrade to unstable?

I have since found that I can set the nix version for my entire system using nix.package = pkgs.unstable.nixVersions.nix_2_26 (given that I have access to unstable packages)

But I guess that may also have unforeseen consequences.

Just so you’re aware, I think the example provided in the changelog is not quite a real useful command call, I recently used the feature so here’s the usage for you: thymis/controller/thymis_controller/task/worker.py at 6aeb2fa85cb201b2885c2cf324709fe8c127aa5f · Thymis-io/thymis · GitHub

So NIX_SSHOPTS="-o 'ProxyCommand the proxy command line'" should work

I just use nix from the source repo (github:nixos/Nix) itself for the binaries with the new env var handling. Hope this helps!

ProxyCommand is pretty much the reason why I wanted to update to that version. With nix version 2.24 when running nixos-rebuild --remote with a ProxyCommand it complained command-line line 0: invalid quotes nixos.
I have since updated my entire system to 2.26 and now it works.

1 Like