Modetc: Move your dotfiles from kernel space
36 points
8 hours ago
| 4 comments
| maxwell.eurofusion.eu
| HN
tengwar2
5 hours ago
[-]
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.
reply
ktm5j
2 hours ago
[-]
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.

reply
mariusor
3 hours ago
[-]
> 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.

reply
user3939382
3 hours ago
[-]
Unfortunately so many packages these days don’t even have a man page at all let alone one with good config info.
reply
mariusor
3 hours ago
[-]
Well ... hopefully they're open source and all that.
reply
brianjlogan
1 hour ago
[-]
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.
reply
skobes
4 hours ago
[-]
Tomorrow: modify man pages from kernel space!
reply
deafpolygon
4 hours ago
[-]
Always check the man pages..
reply
yokoprime
5 hours ago
[-]
I struggle to see a valid usecase for this that isn’t handled by symlinks.
reply
rnhmjoj
1 hour ago
[-]
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.

reply
regularfry
5 hours ago
[-]
If I symlink ~/.ssh -> ~/.config/ssh, I still have .ssh in my ~. Whereas if I rewrite it, I don't.
reply
hvenev
5 hours ago
[-]
Will you not have `~/.ssh`? If you have `.ssh .config/ssh` as a rewrite rule, `stat ~/.ssh` will still find it.
reply
txtsd
5 hours ago
[-]
The point is to have a clean home directory.
reply
jl6
4 hours ago
[-]
Abandon hope.

I just treat ~ as a system-owned configuration area, and put my actual files (documents, photos, etc.) in a completely different hierarchy under /.

reply
oftenwrong
1 hour ago
[-]
I have been doing this for decades. My files are in a sub-directory of $HOME. It also makes it very obvious when a piece of software does not treat your $HOME with respect.
reply
trollbridge
2 hours ago
[-]
You could write a kernel module, then, that just hides certain symlinks from you (which is effectively what this module is).
reply
user3939382
3 hours ago
[-]
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.
reply
pimlottc
2 hours ago
[-]
I didn’t understand what this was from the title. Perhaps a better description would be “mod_rewrite for your homedir”
reply
user3939382
3 hours ago
[-]
I absolutely love this and have wanted to take the time to build this for years precisely because of dotfiles. Thank you!
reply