Lock file error

Since today I’m getting

sudo nixos-rebuild switch                          
building the system configuration...
error: lock file '/nix/store/ncas0cl39dnz05vmcxkgb1nqzrqylnxb-source//flake.lock' has unsupported version 7

How do I fix it?

You need to upgrade to a more recent version of Nix that supports the new lock file format.

nix profile install nix#nixFlakes                    
error: lock file '/nix/store/im96fvb0is9bp8pq42d2mr1w2b9pcb4w-source//flake.lock' has unsupported version 6

That’s the problem:to update to a version that support the more recent lock file I need the flake with the most recent lock format

I guess nixos-rebuild has hard coded a older version of nix than your profile.

You can try to run

nix shell '.#nixosConfigurations.default.config.system.build.toplevel' -c switch-to-configuration swtich

to build and activate your system configuration with your current version of nix.

Of No because I have an older ofnix

Sorry, I thought only the rebuild was the problem. In this case, you can pull in a newer nix version from nixpkgs:

nix shell 'nixpks#nixFlakes' -c nix shell '.#nixosConfigurations.default.config.system.build.toplevel' -c switch-to-configuration swtich

or

nix profile install nixpkgs#nixFlakes
nix shell '.#nixosConfigurations.default.config.system.build.toplevel' -c switch-to-configuration swtich

That too failed because also the nix flake has a version too high