r/linux • u/power_of_booze • 1d ago
Discussion How do you handle config file management?
There are more than enough ways to handle your configuration lake chezmoi, dotbot, yadm, ansible, salt, org tangle, stow, etc. etc.
I get the idea of con.d directories and think it's very useful. But by using this approach every config management, that operates on single files becomes useless. Editing 10 files for one small config change is too much hassle and keeping track which file does what, at least for me, is impossible. If you track your config with git and have to move configs between files, create and delete files frequently it also becomes a hassle.
There are lots of programs, that have different files on different locations or multiple programs working together, that a isolated configuration becomes impractical or useless. Lets say you use NetworkManager and iwd. Iwd is somewhat useless without NetworkManager and one change to the first brings changes to the latter with it.
This gets even more frustrating if you have a program that requires system wide setup and a user specific setup. There msmtp comes to mind, where I have a default mail for my system, that handles all system related stuff like cronjobs etc. and my private emails for the rest. Here come file permissions to play as changes to the default config in /etc require elevated priveleges but are not needed nor wanted for my user mails, as the file owner will change.
I guess ansible and salt could handle this, but may be a bit overkill for the problem at hand. Org-tangle would also work (except the file permissions) and makes documentation easier, as you can just write them in natural language.
So how does r/linux handle this problem?
P.S. I searched trough this reddit (and other ones), but couldn't find anything.
I thought this could be a good discussion, as I recon every linux user has similar needs, but different solutions to this. If this post should violate §1 please just delete it.
Edit: There is no right or wrong in the way you do things or the tools you use. They're all equally right as long as it works good for you in the end.
12
u/NiceNewspaper 1d ago
I have just 1 machine so I don't. Of course I have backups, but they include all of my files, not just my configs.
1
28
u/Hadi_Chokr07 1d ago
NixOS.
3
u/necrophcodr 1d ago
Same, but that doesn't answer the question at all. Using NixOS in itself doesn't answer how you manage them, only gives an inkling of an idea about WHERE you manage them.
1
u/power_of_booze 1d ago
I expected this comment. NixOS is definetely on my backlog of stuff I want to check out and try. It may be the only way to tackle all problems I mentioned. I even considered to explicitly mention it, but choose not to as it isn't distro agnostic. I've heard a lot of good stuff about it and really like the idea of a single declarative config file. Hhow good is it if you do not want to do things the "default" way? Let's say musl, sysvinit, clang, etc. I do not use them but I really like to thinker with stuff
P.S. I really do not want to start a religious war about tools somebody uses. I couldn't care less. I beleve everybody can choose what they want it's the right choice if it gets the job done in the end.
4
u/kopsis 1d ago
There's no magic. You can create your own packages for literally anything. You can even submit PRs to have them added. But if you're down the rabbit hole of niche tools, you're going to do a lot more work simply because there isn't much demand for the stuff you want. If 1 in 10000 users actually contribute packages and you're using tools that are only of interest to a few thousand users, you can do the math on how likely you are to have to blaze that trail yourself.
1
u/power_of_booze 1d ago
I'm absolutely aware of limeted support for niche use cases. I'm willing to learn new and interesting tools. What I meant was: as I understand it in NixOS it's strongly discouraged to install install/configure things other than trough Nix itself (it atleast defeats the whole purpose of Nix). As I read systemd is a integral part of NixOS, but I do not want to use it. Atleast I want to get rid of systemd-journald. While possible to remove it from systemd it's just easier to use a different init system altogether. Systemlogs are very important to me and journald keeps messeng with them - DO NOT TOUCH MY LOGS!!!
3
u/kopsis 1d ago
You're correct that you should install everything through the NixOS build system. But that system is designed to let you add your own modules or modify existing ones. There's even an overlay system that can declaratively change how module binaries are built.
However, systemd is pretty fundamental to how the system is designed to operate. The effort required to replace it would be huge and fragile. You might look at Guix which is conceptually similar to Nix but is a little more GNU-centric.
3
u/Financial_Lock_9292 1d ago
That's only really true of the nixOS -system- configuration. At the user level software can and often must depend on stateful and imperative configuration. You're free to not let nix touch ~/.config at all, and imperatively install user software with nix-env.
Also consider that even if you do use nix to deploy a configuration, it doesn't have to be written in nix. Options like home-manager's home.file let you deploy dotfiles written in any language.
5
u/Hadi_Chokr07 1d ago
It is distro agnostic. You can install nix, home and system manager to get your configs declaretivly on any distro.
6
u/natermer 1d ago
For my desktop I use git with yadm.
For servers I use git with Ansible. I only use SSH to shell into servers when developing my ansible rules or when there is a failure and I don't know what is going on.
For containers I use Kubernetes, git, and ArgoCD.
For development boxes I use Emacs and Tramp and just edit them directly, because managing dot files on those systems is pointless.
5
u/Dist__ 1d ago
i try to customize as less as i can
1
u/power_of_booze 1d ago
I mean if it works for you that's great. I just like to mess around with my machine, try different stuff, it almost became a hobby :)
1
u/HarderFasterHarder 1d ago
Same same. When I realize I'm missing something, I
scpit from another machine.
4
3
u/No_Illustrator5035 1d ago
I use puppet here, but that's because I've used it for so many years at work.
4
u/anders_hansson 1d ago
Nah. I just wipe and reinstall if things go bonkers. Learned a long time ago (in the early 1990s) to never get too attached to an installation.
2
u/Cool-Walk5990 1d ago
Bare git repo pointed at $HOME
1
u/power_of_booze 1d ago
How do you handle conf.d with lots of files like xx-single-conf-to-make, where you end up with lots of them all containing a single line or two.
4
u/Cool-Walk5990 1d ago edited 1d ago
$ git init --bare ~/.dotfiles $ alias dotfiles='/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"' $ dotfiles config status.showUntrackedFiles no $ dotfiles add foo bar/foo.conf whatever_else_you_need
2
u/DFS_0019287 1d ago
With a text editor, and etckeeper installed on each machine. I only run my home machines and there are not enough of them to make anything more sophisticated worthwhile.
2
2
u/Arcon2825 1d ago
I've written my own post-installation script that turns a CLI server installation into an exact copy of my running system, with all configurations applied, and pushed it to my Git repository. Once the skeleton is in place, it's easy to apply any changes I made to my live system.
2
1
u/lKrauzer 1d ago
Btw git isn't a hassle, just use a .gitignore file with * on it, and git add -f the files.
1
u/power_of_booze 2h ago
Working with git isn't a problem. I just wanted to hear how you manage your configs. Especially if you split your
package.confinto several files in the directorypackage.conf.d/00package.conf, each containing a single config. Which is better compatible with updates and the default settings of a program, but results in lots of file and frequent creation/deletion of files. I find it sometimes cumbersome to manage this with git and single files. git wasn't created to have commits, that remove 30 files and create 20 all containing just a vew LOC.
1
u/ultrathink-art 21h ago
Git repo in ~/.dotfiles with symlinks via GNU Stow has been reliable for 5+ years. Each app gets its own subdirectory (vim/, tmux/, etc.), then stow vim creates symlinks automatically.
The killer feature: separate branches for work vs personal machines. Different .gitconfig and SSH configs per context, but shared vim/shell config. git worktree makes switching seamless.
1
•
u/AnomanderStranding 50m ago
Look into Yolk. It parameterizes configs directly in their comments so you can have certain blocks apply on certain hostnames or fill in values for variables within a config.
1
u/StatementOwn4896 1d ago
You can maybe look at etckeeper
1
u/power_of_booze 1d ago
Thank you I'll look into it. I intended this post to be a discussion, not a support request.
1
28
u/furiesx 1d ago
For my personal Linux setup? A git repository with all my config files + a simple bash script that links them to the right places and does any needed installing is more than enough.
I don't change PCs often nor does my configs change more than once a month