Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strategies to deal with renameat(3) on persisted files #175

Open
Ma27 opened this issue Mar 27, 2024 · 1 comment
Open

Strategies to deal with renameat(3) on persisted files #175

Ma27 opened this issue Mar 27, 2024 · 1 comment

Comments

@Ma27
Copy link
Member

Ma27 commented Mar 27, 2024

Suppose you have a configuration like this:

{
  environment.persistence = {
    "/impermanence/safe" = {
      directories = [
        "/etc/wpa_supplicant.conf"
      ];
  };
}

Now, wpa_supplicant appears to do a rename when writing changes to the config which is state I'd like to keep.
A similar issue also exists for ~/.local/share/recently-used.xbel or .gdbinit.

This doesn't work if only the file is persisted (i.e. bind-mounted) since a rename fails with EBUSY in that case.

There are two kinds of workarounds:

  • use symlinks (with Allow for symlinking files #146): works for a few applications, e.g. gdb. But GTK (for recently-used.xbel) and wpa_supplicant replace the symlink with a file then.
  • patch around in the NixOS module to use another config file. For wpa_supplicant that was my fix (Ma27/nixpkgs@d90b3eb, note: I use allowAuxiliaryImperativeNetworks). Now I can persist /etc/wpa_supplicant[1] and the move inside works fine. This however is not feasible for recently-used.xbel which seems to be backed into GTK and would cause an excessive amount of rebuilds for me (and I don't really want to use libredirect for ~everything on my desktop).

What I'm wondering is, is there any feasible, generic way that doesn't require us to find solutions per-application?
If so, we may want to consider adding those as another alternative into impermanence.

[1] https://docs.gtk.org/gtk4/property.Settings.gtk-recent-files-enabled.html

@DarkKronicle
Copy link

This isn't optimal, but I think it would work in this situation. If using btrfs subvolumes, on boot (or at least before a lot of services start), you could copy the file into your /persist location, and then copy that over to the actual location.

For example, if this is your persist:

/persist/recently-used.xbel (mtime 4/02)

Then on boot:

/last_boot/home/.../recently-used.xbel (mtime 4/03) -> /persist/recently-used.xbel
/persist/recently-used.xbel (mtime 4/03) -> /home/.../recently-used.xbel

This has the downside of not being persisted until after boot happens again, but on btrfs this copy could be essentially free with --reflink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants