Config migration causes problems on NixOS
The migration feature causes lazygit to not open anymore on NixOS, as the config file in on a read-only file system. It would be great, if this would only throw a warning instead of not starting at all. Here is an example of a failed migration:
The user config file /home/USER/.config/lazygit/config.yml must be migrated. Attempting to do this automatically.
The following changes were made:
- Changed 'subprocess: true' to 'output: terminal' in custom command
2025/05/26 04:18:21 While attempting to write back migrated user config to /home/USER/.config/lazygit/config.yml, an error occurred: open /home/USER/.config/lazygit/config.yml: read-only file system
This was discussed here: https://github.com/jesseduffield/lazygit/pull/4210#issuecomment-2614298403
I did look into making it only a warning, not a hard error, but it turned out to be difficult to do. For that reason I decided to only do the other improvement, which is to print the changes that need to be made to the config file, so that users with a read-only config file can make these changes manually.
I'm not familiar with NixOS, so if I'm missing some reason why this is not a workable solution, please explain.
The information about the specific setting is definitely helpful in fixing it in the config. Just that under nixos the change requires a rebuild of you nixos or home manager config or both. This doesn't take that long normally but is a blocker if you just want to commit (push, merge, pull, etc.) something quickly. Maybe there could be a ignore switch or similar to be able to just start lazygit and finish the task at hand before adjusting the config?
I have this issue as well.
@stefanhaller, NixOS works (in short) by putting symlinks in specific places that link to a directory in /nix/store. So the configuration for lazygit would be at /nix/store/<hash>-lazygit.conf. The configuration is put in place by adding a symlink from the nix store path to ~/.config/lazygit. All directories in the nix store are read only.
Maybe a solution would be to add a configuration option with a path to save the state file? If I can manually set it to /tmp/lazygit/state.yml everything would work as intended.
If viewed positively, I can create a PR.