Nixos-rebuild switch error: adding a file to tree builder

Oh, right, I didn’t consider that that’s also using a flake reference.

nix shell --impure --expr '(import (builtins.fetchTarball "https://channels.nixos.org/nixos-24.11/nixexprs.tar.xz") {}).nixVersions.nix_2_18'

Should get you in a shell with nix 2.18.

EDIT: If even fetchTarball fails…here’s the hackier option.

You can download a static build of lix (sorry, I couldn’t figure out how to provide a hydra link to static nix 2.18) from here:
https://hydra.nixos.org/job/nixpkgs/trunk/lixStatic.x86_64-linux/latest/download-by-type/file/binary-dist

Make sure the file is named nix, rename it if it isn’t, and mark it executable.

Then do something like export PATH="/newpath:$PATH" to temporarily add it to PATH. (where /newpath is the directory containing the file you downloaded).

Then continue with your nixos-rebuild.

That will be a waste of your time, it’s a nix bug, rebuilding the same config with the same nix will lead to the same result.

2 Likes