Error: unsupported tarball input attribute 'lastModified'

Yesterday, my laptop died and I needed to resurrect a spare laptop to work on.

This laptop was running an outdated version of NixOS, old packages, a different window manager and other things, so I tried to update it to bring it up to date so it's up to date with my dead laptop's configuration.

Doing so, though, gave me this error:

Error: unsupported tarball input attribute ‘lastModified'

A normal sudo nixos-rebuild switch worked, but trying to use a Flake was generating the error.

I was able to get it working after running these commands from a Discourse thread:

nix shell "github:NixOS/nix/2.18.4"

nix build .#nixosConfigurations.nixedo.config.system.build.toplevel

sudo nix-env --profile /nix/var/nix/profiles/system --set ./result

./result/bin/switch-to-configuration switch

I also needed to add --experimental-features 'nix-command flakes' to the nix commands to get them to run.

Once this finished, I was able to reboot and get a running up-to-date configuration.