Live data from Hacker News

Using GNU Stow to manage your dotfiles (2012)

brandon.invergo.net

51–60 of 116 posts

Re: Using GNU Stow to manage your dotfiles (2012)

#51
post #43

Earlier quoted context omitted.

Right, but when you unlink it from your home directory, the file still exists in the git repo. So there is a manual synchronization that must happen between the two directories.

> Right, but when you unlink it from your home directory, the file still exists in the git repo. That's a feature.

`git rm` will still leave the file available in the repo history, so violating the consistency seems more like a bug than a feature.

Re: Using GNU Stow to manage your dotfiles (2012)

#52
post #43

Earlier quoted context omitted.

> Right, but when you unlink it from your home directory, the file still exists in the git repo. That's a feature.

Not when you are looking for a workflow to make dealing with dotfiles faster and more painless. With the current (symlink based) setup, there is a hidden state you must hold in your head or else carefully inspect: the discrepancy between your git repo and your home directory. Maybe you forgot to link a dotfile, and that’s why your latest configuration doesn’t work. Ditto for unlinking a dotfile.

Isn't that what -D, -S, and more simply -R do?

I did not use stow 2.x, but my understanding is that running stow -R will allow you to remove previous dangling symlinks (during the unstow) and add missing symlinks (during the restow). Effectively allowing you to only manage a single state: your git repository.

Re: Using GNU Stow to manage your dotfiles (2012)

#53
post #29

Call me old fashioned but what's wrong with having a regular git repo anywhere you want with all of your dotfiles and them symlink those files to where they need to go? If you wanted to you could && a few symlinks and other commands into 1 copy / paste'able command to get up and running really quickly. It's also painless to manage secrets by sourcing in optional files. It also works nicely when you want files living…

That's what I do too. I even made a little Stow-inspired tool to help me, called "stowage", if you are curious: https://github.com/michaelpb/stowage

Re: Using GNU Stow to manage your dotfiles (2012)

#54
For this I highly recommend https://zolk3ri.name/cgit/zpkg/ which I have been using for years now. It works wonderfully for my use case, and might work for yours, too. It is very simple.

Environment variables and their defaults:

    ZPKG_SRC = ~/.local/pkg
    ZPKG_DST = ~/.local
    ZPKG_DB = ~/.local/pkg/.db
It means that if you install anything from scratch, you have to `make install` (or the like, depending on the build system) it to, say, `~/.local/pkg/foo-1.0` and then run `zpkg link foo:1.0` to install (i.e. link) the "package".

After that you just have to make sure you have (typically in your `~/.bash_profile` file):

- added `~/.local/bin` to your `PATH` environment variable, and

- added `~/.local/man` to your `MANPATH` environment variable

Seems to do the job. For help, read the source code or type `zpkg --help` which should be of tremendous help.

By the way, I have noticed that someone created a package manager with the same name, but its initial commit was in 2019, while this one's was in 2017.

It is written in OCaml, so you do need to have the OCaml compiler installed. I recommend doing it via `opam`, but your Linux distribution's package manager will suffice (simply `ocaml` on Arch Linux, for example). Run `make` to compile it, it will produce a working executable file.

Direct link to the source code: https://zolk3ri.name/cgit/zpkg/tree/src/zpkg.ml

If you find any bugs, report it via e-mail which can be found in the `LICENSE` file. I reported a bug before and it was fixed almost immediately. I suppose you can send pull requests or mention missing features, the creator seemed friendly to me.

---

The above is a modified version of an old comment of mine: https://news.ycombinator.com/item?id=24238587

---

To be frank, I forgot how it compares to GNU Stow because it was many years ago, but I did use GNU Stow prior to finding this program. All I remember is that it is way simpler, and it seemed to be perfect for my use case, no more and no less than what I needed. Maybe it works for you, too.

Re: Using GNU Stow to manage your dotfiles (2012)

#56
You don't need symlinks, setup scripts, etc. Try this:

1. Bare git repo in your home directory ($HOME/.files)

2. Alias for prefixing git commands ("env GIT_WORK_TREE=$HOME GIT_DIR=$HOME/.files")

3. Strict .gitignore file (that ignores all files by default)

Simple to add files: `h git add .vimrc`

Have this set up for myself. Works great https://github.com/tmm/dotfiles

Re: Using GNU Stow to manage your dotfiles (2012)

#57
post #56

You don't need symlinks, setup scripts, etc. Try this: 1. Bare git repo in your home directory ($HOME/.files) 2. Alias for prefixing git commands ("env GIT_WORK_TREE=$HOME GIT_DIR=$HOME/.files") 3. Strict .gitignore file (that ignores all files by default) Simple to add files: `h git add .vimrc` Have this set up for myself. Works great https://github.com/tmm/dotfiles

This is similar to a resource that atlassian has put out on storing dotfiles [1]. It is also similar to what I use and I can vouch for this method as well.

[1] https://www.atlassian.com/git/tutorials/dotfiles

Re: Using GNU Stow to manage your dotfiles (2012)

#58
post #7

I have found that managing dotfiles is not enough. The dotfiles serve no purpose without the software that uses them. My method is to write small scripts, I call them setuplets, that install the software and then symlink the dotfile to its master that I manage in git. In the simplest case, it is just a two line script in a directory, but I have one for each program, and a tool to select which I run when setting up a…

Interesting! https://github.com/nix-community/home-manager uses Nix to solve this problem. It adds reproducibility and rollbacks but with the cost of learning the Nix DSL.

+1 for nix and home-manager - I recently switched to this setup (still learning/experimenting a lot, link here [0]) and have been very happy!

[0]: https://github.com/jpetrucciani/nix

Re: Using GNU Stow to manage your dotfiles (2012)

#60
post #7

I have found that managing dotfiles is not enough. The dotfiles serve no purpose without the software that uses them. My method is to write small scripts, I call them setuplets, that install the software and then symlink the dotfile to its master that I manage in git. In the simplest case, it is just a two line script in a directory, but I have one for each program, and a tool to select which I run when setting up a…

I don't want to sound condescendant, but are you not basically doing packages ? Instead of standard packages your distro gives you, you have "custom" packages that also contain more specific installation instructions (write file with specific content, set environment variables, ...). I know that PKGBUILDs in Arch allow you to do such things if needed.

Bonus: now even configuration files can be linked to the software that needs it; when you remove a software you also remove all the files related to it and there are no leftovers.

Post reply on HN