Nix flake registry error: "error: cannot write modified lock file of flake 'flake:nur'"


yesterday I had some spare time and I spent it to migrate my laptop configuration to use flakes. To that purpose, I gave another read to @edolstra nice blog entry on managing nixos config with flakes then i skimmed through nixos’ wiki flakes page to know what it had to say on the matter; I also gave a look to @nrdxp DevOS repo. I came out with a working configuration that pleases me, you can have a look at it here.

While setting up all the pieces I familiarized with the concept of the flake registry and I found out that it’s actually the union of three registries, the global, the system, and the user’s. The global is a repo on NixOS github group, the system one is in /etc/nix and the user’s one is in ~/.config/nix.

It can be modified imperatively by using thenix registry [add| ... ] but also by configuring the nix.registry submodule as I do here. This way, the nixpkgs release is pinned and will not be downloaded again when running nix search nixpkgs foo.

Nice! I played a bit the registry but I’m now stumbled on an error returned by commands like nix flake show nur (nur flake is in the global registry):

$ nix flake show nur
error: cannot write modified lock file of flake 'flake:nur' (use '--no-write-lock-file' to ignore)
(use '--show-trace' to show detailed location information)
$ nix flake show nur --show-trace
error: cannot write modified lock file of flake 'flake:nur' (use '--no-write-lock-file' to ignore)

       … while updating the lock file of flake 'path:/nix/store/02nbfm4mc8r5iv80w6p9pash6nhgsyk4-source?lastModified=1619994493&narHash=sha256-cYKOTkRp1J0DIrJ6MNBH4dAmpQGaf2shppxKuI0eIac=&rev=72fd1387746e2d2806e1ec172886c149c3f46180'

… this happens even if I’m root (but I don’t know if that should change anything).

Now, I can obviously add the --no-write-lock-file on the command line, but I wanted to play by exploring flakes in the repl using the builtins.getFlake function and that too raises an error and doesn’t complete the operation. There’s no doc yet for that function so I don’t know if it’s possible to pass options like the no-write-lock-file to it.

Does anyone have some experience with the registry and can shed some light on the error?


Thanks for the nice writeup, this would make a nice addition to the wiki I think :slight_smile:

I don’t know what’s happening, but I could confirm that it doesn’t happen with all flakes in the global registry, e.g. nix flake show blender-bin works (sidenote: no idea why Blender is there tbh).

I did just put together bits and pieces that others documented in the first place… what do you think it’s best: a new page or an addition to the flakes one? (cc @Mic92 )

oh, you are right… any other entry in the registry seems to work (I didn’t try them all) … my bad! I don’t know why nur is different though