Restore configuration files from the current NixOS

Hi everyone.

Is there any way to recover the configuration files from a currently running NixOS?

I know this seems impossible.
But any suggestions are welcome.

Background

Honestly, this is the dumbest ‘hacker’ attack I’ve ever seen. But it wouldn’t be funny if the victim were me. A 7-year-old kid just walked into my room and deleted all my remote repositories and most of my local data—can you believe that?

I set up full-disk encryption and secure boot to protect my data, and of course 2FA to safeguard my remote repository. And then all of that protection turned out to be useless. He didn’t even know my WM key bindings; he just happened to see my computer on, with Firefox and a terminal open, and I had just verified 2FA to add an SSH key. And then he delete all my repos!!! And then run rm -rf *!!! “JUST FOR FUN”!!!

我草这bydxbzz怎么那么坏啊

Do you use flakes or did you enable system.copySystemConfiguration? If yes, this is a lot more possible.

Thanks for your quick reply. Unfortunately, neither. I don’t use flakes to build NixOS. But I do use flakes to manage some packages, and the NixOS configuration is included in the same repository. Does Nix copy the whole repository to /nix/store? Is it possible that the repository is still in /nix/store?

Correct, when using a flake.

Assuming garbage collection hasn’t happened since, yes.

Thanks. I think I can try looking for it.

I’m not sure if this helps, but the store path will be of the form /nix/store/<hash>-source, since the flakes just get a generic name source. You may be able to search for a flake.nix or other specific filename in those paths.

Is it possible that web archive or other archives (or repo archivers if there are such stuff) may have your config in your remote repos stored?

Is it also possible to ask the repo hosters to maybe recover your data?

1 Like