Restore store files if deleted by an application

I ran firecfg application not knowing the consequences. Then ran firecfg --clean thinking it would reverse the damage.

Now I have a lot of *.desktop files removed from the store.

What is the best way to restore missing files of the store?

What do you mean, they are missing from the store?

Nothing but nix should ever be able to change anything in the store, unless you are running on non-nixos, and even then it really shouldn’t be easy. Even single-user installation shouldn’t allow just deleting files without some extra steps.

Anyway, if in fact the store has some broken paths, you usually can fix them by running nix-store --verify --check-contents --repair (perhaps using sudo/doas depending on details)

1 Like

nix-store --verify --check-contents --repair should repair any substituted store objects. If the store objects were locally created, though, there’ll be more annoyance.

I am also curious how your program managed to actually modify the store. What kind of environment are you in? In any environment, the whole directory structure should be marked read-only, so the program would have had to detect that and clobber the permissions (which is pretty bad programming practice to begin with). In many environments, such as nixos, it’s quite a bit harder even than that.

1 Like

Thank you for the help, so I am probably wrong that they were deleted from the store.

Are all the wrapped modifications of an application stored in the store? So they also would have been repaired? Or can some application put a file out of store during installation?

Nix can not operate outside of the store, though there is a lot of auxiliary tooling that does create things outside of the store, those this again are just symlinks into the store in way more than 99% of cases.

1 Like

Configuring programs by wrapping puts everything in the store and linked from the wrapped executable.

Configuring programs with nixos or home-manager modules generally puts links to files in the nix store into place in /etc or ~. Those links can be restored if deleted by rerunning the activation script for the generation of nixos or home-manager. Or simply by rebuilding.