Modetc: Move your dotfiles from kernel space

15 days ago (maxwell.eurofusion.eu)

One of the annoyances of Linux is working out where configuration information is, following through multiple layers of indirection and files over-riding other files. This looks like adding another layer, another place to look, and if you're reading the man file for a shell (for example) it probably won't even mention that this could invalidate the information contained in that in the man file.

  • > working out where configuration information is

    Generally, good behaved applications have an entry in their man page that spells out these details for you, so you don't have to work out anything.

  • You're not wrong. In a worst case scenario I resort to using strace to figure out where a program is reading config from.. from what I understand, if this kernel module is in use then even that approach wouldn't help.

    But since the use case is personal dotfiles, I imagine the user isn't going to forget that they set this up.

  • To be fair the author shows an example of using NixOS. It's absolutely another layer of indirection (probably several) but it does make that usual Linux "fun" less problematic because of its immutable nature and API design.

  • > this could invalidate the information contained in that in the man file.

    No, it doesn't. The point of modetc is precisely keep both myself and the programs happy: the files are actually stored where I like to keep them, but they can be accessed as if they were stored where the developer intended.

  • Always check the man pages..

    • And I said that the man pages would be a part of what you have to examine. 95 pages in the case of bash (that's after running it through troff). man pages were fine when they were three pages long, but their lack of any internal index has become a problem.

      Ok, now you might have a dozen files which could contain the information, where the location of each file can be modified by environment variables. It's tolerable if you are working on something you change weekly, but a practical problem if you do it yearly or it's entirely new.

      3 replies →

I didn’t understand what this was from the title. Perhaps a better description would be “mod_rewrite for your homedir”

I struggle to see a valid usecase for this that isn’t handled by symlinks.

  • Hi, author here: whether it's a valid use case depends on your level of OCD, but the difference compared to symlinks or bind mounts is that you will have a clean home: e.g. `ls -la` won't show any "hidden" files.

    Also, completely unrelated to my motivation, someone pointed out that modetc could be used to quickly hotfix packages built with Nix. Say that you need to fix a CVE in openssl, normally that would require to rebuild all dependent packages, which takes a long time. Instead with something like modetc you could build just openssl and rewrite /nix/store/<hash>-openssl-3.6.0/ -> /nix/store/<hash>-openssl-3.6.0-hotfix/.

    Another application might be replacing some configuration file with placeholders for secrets, with one file with the secrets substituted in, without having to modify it in place, possibly only for a specific UID. This is something you might find useful on NixOS.

  • The use case is that you can actually use your home directory without either (a) hiding files or (b) wading through 40 config files and dirs that XDG ignorant devs put there.

From the example:

  # XDG "compliant" programs
  .config/ etc/
  .local/state/ var/lib/
  .cache/ var/cache/

This is the first I’ve heard of using ~/etc instead of ~/.config as $XDG_CONFIG_DIR. Is there any precedent for that?

  • Well, it's just the natural extension of the FHS convention to the home directory.

    I didn't come up with this idea, though, I think I saw this in a reddit thread and started doing it myself: I like that the directories are visible and follow the usual structure.

I absolutely love this and have wanted to take the time to build this for years precisely because of dotfiles. Thank you!

Every time I see yet another dotfile-management solution I just can't help but wonder: maybe it's the dotfiles that are the problem?

XDG doesn't handle complex environments, especially not heterogeneous computing environments. Something long the core strength of Unix is acknowledged by XDG and then left utterly unaddressed. Without this, the "standard" is as much an impediment as an aid.

It's amusing that modetc goes through all this effort to twist dotfiles into the XDG half-solution, and here I am using symlinks through /dev/shm/xdg/* to warp XDG into sort-of working in an actual heterogeneous environment.

Because XDG by itself is a failure beyond trivial cases.