Nice hack, but I still believe that home-manager [0] should be the way to go. It's the gateway drug to the Nix ecosystem and cleanly solves the composability problem which this "one-size-fits-all repo checked out to root" approach will have some trouble with.
From this HN comment from 2016 https://news.ycombinator.com/item?id=11071754
I use:
git init --bare $HOME/.myconf
alias config='/usr/bin/git --git-dir=$HOME/.myconf/ --work-tree=$HOME'
config config status.showUntrackedFiles no
where my ~/.myconf directory is a git bare repository. Then any file within the home folder can be versioned with normalcommands like:
config status
config add .vimrc
config commit -m "Add vimrc"
config add .config/redshift.conf
config commit -m "Add redshift config"
config push
And so one…No extra tooling, no symlinks, files are tracked on a version control system, you can use different branches for different computers, you can replicate you configuration easily on new installation.
Checkout chezmoi, I’ve been using it for a few years and it ticks every box for me - various machines, different configs, scripts, passwords etc
Dotbot (https://github.com/anishathalye/dotbot) has worked extremely well for me. It’s simple to setup, has minimal dependencies, and it is also easy to run arbitrary commands if I want to get tricky with things. I would highly recommend it.
I always start out with the best of intentions for dotfile mangement etc, using tools like stow, git and so on.
Eventually I get lazy and don't bother checking stuff in and forget where half of the stuff is.
Might try this solution but I'm too cynical to think it'll be something I'll stick with
~/.dotfiles
Really? Just as so many utilities are finally moving away from `~/.foo` to `$XDG_CONFIG_DIR/foo` (default `~/.config/foo`) to reduce home directory pollution, does a new tool have to start using `~/.foo`?Heck, even the `dot` output demo'd by TFA shows 8 legacy `~/.foo` files, but 10 `~/.config/foo(/bar)*` files. (But is missing `~/.dotfiles`?!)
YADM[0] is another great tool for this very purpose which I've been using for years in combination with homebrew to setup any new (Mac) machine that I get and have everything from dotfiles to Applications installed in no time.
[0] https://yadm.io
I was unhappy with existing solutions, especially I wanted the ability to handle differences between machines. So I built my own! You're welcome to see if you like it :)
I'm a fan of just having my $HOME as a plain git repo with "*" in ~/.gitignore. Having to force add new files is a minor chore but one I'm more than happy to live with.
At our startup (FluxNinja), we provide MacBooks and Linux Desktops (System76) to our engineering staff. We have invested in common dotfiles[0] to help them keep dev experience consistent across machines. We use chezmoi for dotfiles management.
Really recommend investing in common dotfiles at the organization level. For young developers, a standard setup provides a big productivity boost.
I also use this trick to manage my dotfiles. Here is another good tutorial about it: https://www.atlassian.com/git/tutorials/dotfiles
How do people here handle secrets like e.g. passwords / env variables / ssh keys in their dotfiles?
I've written simple encrypt/decrypt with PGP, but since I've kinda lost trust into Keybase I have no simple way to bootstrap PGP.
I very recently put some effort into tidying up my dotfiles, and have a brief writeup at https://chatwithsysop.com/blog/2022/12/31/dotfiles-cleanup (none of this was done with the academic rigor required to withstand a deconstruction by HN, it is just a log of one person's experience with a weekend project).
I chose to use yadm (http://yadm.io) for no particular reasons beyond that I found it first, and it seemed reasonable. It's more just a wrapper around putting GIT_DIR elsewhere.
As more applications migrate to xdg, I have simply taken to having my .config directory be a git repository.
Inside that directory I have a “dotfiles” subdirectory that has managed versions of my home directory dotfiles which I symlink in.
Cool, but I don't need everything versioned and I like it simple.
~/usr/src/p/dotfiles git worktree list
/home/matt/usr/src/p/dotfiles 160721b5e3 [master]
/home/matt/.config e195a59c7b [config]
/home/matt/.gnupg b50725b47c [gnupg]
/home/matt/.mozilla b5d0d07b74 [mozilla]
/home/matt/.mutt f3d4a14d99 [mutt]
/home/matt/.tmux a93aa509af [tmux]
/home/matt/.vim 68fd61921c [vim]
/home/matt/.weechat ef3d4c761f [weechat]
/home/matt/.zsh 228ee42367 [zsh]
/home/matt/bin b05de7d9d7 [bin]
/home/matt/usr/venvs/shell 6a3b7e4c6a [shell/venv]
/home/matt/usr/venvs/npm d2065c68bf [shell/npm]
And only two symlinks I manually manage /home/matt/.vimrc -> .vim/.vimrc
/home/matt/.zshrc -> .zsh/zshrc
Everything else isn't versioned. I rely on btrfs snapshots and back ups.In case it's useful for someone (xkcd.com/1053) I use stow for handling config files. Lastly featured in HN here: https://news.ycombinator.com/item?id=32253018
It does however need a bit of preparation for complex things like Electron-based apps. I don't want to stow non-essential files and dirs, so I ended complementing it with a small script to do some preparation before the stowing itself.
I see a lot of people mentioning home-manager / nix in the comments. I tried drinking the nix kool-aid and home-manager and all that was a little too much more me and landed on a hybrid approach:
https://github.com/sontek/homies
1. I use a `justfile` that calls `nix profile install ...` to install my packages, rather than using a nix configuration file. This allows me to use a standard package manager workflow rather than going "all in".
https://github.com/sontek/homies/blob/master/justfile#L24-L2...
2. I then use GNU Stow to install my dotfile configuration:
https://github.com/sontek/homies/blob/master/justfile#L93-L9...
I think this is a great middle ground where I can utilize `nix` as my package manager across Linux and Mac and have consistency while not having to learn the whole configuration language or change my workflow.
The other tools I use heavily in my environment:
- https://asdf-vm.com/: I find this better than installing python/node/etc from nix.
- https://github.com/casey/just: I use this as my command runner (similar to make but cleaner in my opinion)
I also track my dotfiles in a Git repo, but I only track my home directory. Made a tool to help out with some of the more arcane commands: https://github.com/tubbo/homer. I'm currently rewriting it in Rust, which is mostly done but I still have to work out a couple kinks on Linux machines . So far, I haven't needed to mess with too many top-level configs on each machine, most of the stuff I do is relatively contained (and uses the XDG standards thankfully). It got a little hairy when I tried to configure certain file paths on both a Linux and macOS environment, as there are different default conventions and other nuances that make the two not fully compatible at times. But it definitely saves a lot of time when setting up a new machine from scratch, `homer bootstrap $REPO_URL` does all the hard work and gets my home directory loaded up with configuration the way I'd expect.
I just use yadm: https://yadm.io/
I did something similar here https://github.com/redraw/dotfiles, along with some installation scripts
although, nice idea on tracking the whole / instead of just ~/!
the only thing I miss after aliasing dotfiles to git, is that you lose git's autocompletion features. I once tried to set it up in zsh with autocomp, but without success, should review that
The biggest pain point I have with dotfile management is that none of my computers are exactly the same, so if I start pulling dotfiles from a repo I get unwanted configuration on a machine. It could be something as simple as a Vim theme not looking right on another computer because it's using a different terminal.
I guess what I should be doing is adding if statements into all of my config files, but instead I wind up just copy/pasting the parts of config that I like from my github repo and never actually doing real dotfile management. Which just leads to the repo becoming stale.
A similar post on HN:
- "The best way to store your dotfiles: A bare Git repository" : https://news.ycombinator.com/item?id=19591033
- Also see: "The best way to store your dotfiles: A bare Git repository EXPLAINED" : https://www.ackama.com/what-we-think/the-best-way-to-store-y...
Hourly snapshots for history.
I hardly ever need to sync things between machines since vscode manages that itself.
I get why some people need this but it's a net time sync for a lot of people that probably don't need it.
Willing to bet it's mostly due to a lack of backups and ability to restore them to a new machine when you upgrade.
One nice thing about this is that you can keep a central repo for multiple machines and use branches with rebase and merge to sync changes while keeping specific differences separate.
I used to put a lot of effort into trying to sync dot files. And you know what? I don't see a reason to do it. I only have one work computer and one personal computer.
I moved away from using a dotfiles repo a few years ago because I kept forgetting to add/commit files as I changed them.
Instead I use mackup[0] which automatically manages symlinks to your Dropbox/Drive/Share and has support for a huge amount of software by default. You can also manually add “extra” files you wish to track if you like.
I use something similar but call it cfg: https://gist.github.com/radupotop/c1d2b77c24ddfcfae93d840f51...
Each local user has its own branch so this works: cfg push -u origin $USER
It's limited to the $HOME config files only, /etc has a separate git repo.
I have a similar system: I manage my dot files and a bunch of other configs by placing a git repository in my operating system's root directory, i.e. file:///.git. I use a .gitignore file to exclude most things from consideration while adding things to git. Transferring to another OS is as simple as copying the .git dir over.
I found that most tooling was overkill and now just use a single <100 Bash script [0].
I personally value Out Of Box Experience, and so, my personalization is more like installing software, instead of tweaking them. So I back up my /home, and on a new system, I just look at the backup, if I need settings for a program.
This isnt a vcs based solution, but I've been using syncthing to track my configs, with the help of a small home server. The bonus is that it automatically synchronises my work and personal laptops without me needing to do anything
Looks similar to what I’m doing to manage my dotfiles [0]
I’ll be refreshing this thread to see what others are using.
I'm a BSD user, so I tend to gravitate towards using rcs. Took a little while to get the muscle memory down, but it does work well for keeping track of my dotfiles.
I previously found the same idea there : https://github.com/Snaipe/dot-git
nix home-manager is really great at this (and declarative!)
Does this approach work with submodules? The reason I ask is because some of my configs rely on configs from other repos.
I've been using this which is pretty rad
Is there a name for oft-repeating content/post and the overall discussion on a given topic (dotfile management in this case) on HN?
I am not complaining about the repeat. It’s just that I find it very amusing to see different people kinda-sorta reinventing the wheel (and discussing the nuts and bolts) again.
That's nice, i just dump them in a GH repo. I get a backup too :)
I do something similar, albeit a bit more bare-bones. I keep my dotfiles in a dotfiles folder that is a git repo and then just have a simple script to symlink everything.
I have a couple of submodules in there (zplug, pyenv) and a bash script to keep them up to date, and then a few self managed binaries, like fnm. That's about it.
I don't bother trying to manage anything outside of home or deal with secret values by using something like git-secret.
Overall, it works great and has allowed me to keep track of how my core tools are configured without too much hassle.