summaryrefslogtreecommitdiff
path: root/content/2022/gnu_stow.md
diff options
context:
space:
mode:
authormms <michal@sapka.me>2023-12-29 23:39:26 +0100
committermms <michal@sapka.me>2023-12-29 23:39:26 +0100
commit339ba0bf872a672fea7d611343df4a6f0e14d585 (patch)
treea76e605040f987947ddf5fe31ca9806fd7f7e61a /content/2022/gnu_stow.md
parent4c6ed817fb1ac3f1585f8fe19376e722a3f994c7 (diff)
feat: move most of 2022 into new locations
Diffstat (limited to 'content/2022/gnu_stow.md')
-rw-r--r--content/2022/gnu_stow.md134
1 files changed, 0 insertions, 134 deletions
diff --git a/content/2022/gnu_stow.md b/content/2022/gnu_stow.md
deleted file mode 100644
index 9c2bc02..0000000
--- a/content/2022/gnu_stow.md
+++ /dev/null
@@ -1,134 +0,0 @@
----
-date: 2022-06-09T19:10:00+02:00
-category: engineering
-draft: fale
-year: 2022
-title: Managing dotfiles with GNU Stow
-tags:
-- GNU
-- stow
-- Linux
-- tutorial
-abstract: A short tutorial.
----
-If you are working with linux/bsd based system, you are most likely accustomed to managing
-your configs with dotfiles. And you most likely have them stored with Git. But there is the
-never ending problem of how to actually use them. I have moved management of this under
-GNU Stow.
-<!--more-->
-Let's take a very typical dotfiles repository.
-
-{{< highlight shell>}}
-./nvim/init.lua
-./tmux/tmux.conf
-{{</highlight>}}
-
-You want to have those files available as
-
-{{< highlight shell>}}
-~/.config/nvim/init.lua
-~/.tmux.conf
-{{</highlight>}}
-
-The most popular approach would be to symlink the files under the expected location. We
-could also copy the files every time something changes, but that would be crazy. Are we
-the stuck with having to do those symlinks manually every time we install a new machine
-or create a virtual one? And what if we have dozens of such configs stored under git?
-
-## Symlink farm
-
-GNU Stow is a symlink farm. This means, that it's a system aimed at automating creating of
-those symlinks.
-
-[GNU Stow website](https://www.gnu.org/software/stow/manual/stow.html)
-
-For Stow, the dotfiles directory is called "Stowed" directory. Now comes the cool part. Each folder
-in the Stowed directory (called "Package directory") stores a separate directory tree. GNU
-Stow will join all those separate trees and create a proper structure under Target Directory,
-which by default is the parent of Stowed directory. Let's look at example.
-
-{{< highlight shell>}}
-~/target/stow/one/config/one.conf
-~/target/stow/two/config/two.conf
-~/target/stow/three/config/three.conf
-{{< / highlight >}}
-
-So, our home director now has a "Target" directory, which has a "Stow" directory. The Stow
-directory stores three configs which we want to sylink as
-
-
-{{< highlight shell>}}
-~/target/config/one.conf
-~/target/config/two.conf
-~/target/config/three.conf
-{{< / highlight >}}
-
-Let's stow the first one
-
-{{< highlight shell>}}
-cd ~/target/stow
-stow one
-{{< / highlight >}}
-
-And see what happened
-
-{{< highlight shell>}}
-cd ~/target
-ls -lA
-{{< / highlight >}}
-
-We get somethine like
-
-{{< highlight shell>}}
-lrwxrwxrwx 1 msapka wheel 15 Jun 9 23:01 config -> stow/one/config
-drwxr-xr-x 5 msapka wheel 4096 Jun 9 22:55 stow
-{{< / highlight >}}
-
-Stow created a config symlink in the target directory. Very cool, but it gets cooler! Let'
-stow the second one
-
-{{< highlight shell>}}
-cd ~/target/stow
-stow two
-{{< / highlight >}}
-
-and what we get
-
-{{< highlight shell>}}
-drwxr-xr-x 2 msapka wheel 4096 Jun 9 23:03 config
-drwxr-xr-x 5 msapka wheel 4096 Jun 9 22:55 stow
-{{< / highlight >}}
-
-Our config is no longer a symlink, but a real folder. Let's see what's inside here.
-
-{{< highlight shell>}}
-cd config
-ls -lA
-{{< / highlight >}}
-
-{{< highlight shell>}}
-lrwxrwxrwx 1 msapka wheel 27 Jun 9 23:03 one.conf -> ../stow/two/config/one.conf
-lrwxrwxrwx 1 msapka wheel 26 Jun 9 23:03 two.conf -> ../stow/one/config/two.conf
-{{< / highlight >}}
-
-We have our two configs, but what has happened? Stow looked at both sub trees for "one" and
-"two"m and joined then in a way, that is possible. The only way for one.conf and two.conf to
-exist in config is if config is a normal directory. Extremely cool!
-
-Let's image that our target is actually homedir, so we have a ~/dotfiles directory. Then
-each package directory can mimic the tree struture of the actual config! Coming back
-to our example, we can have a
-
-{{< highlight shell>}}
-~/dotfiles/tmux/.tmux.conf
-~/dotfiles/nvim/.config/nvim/init.lua
-{{< / highlight >}}
-
-Then, after stowing both packages we have symlinks under our desired
-
-{{< highlight shell>}}
-~/.config/nvim/init.lua
-~/.tmux.conf
-{{< / highlight >}}
-
-GNU Stow is a very simple tool. All we understand what will happen with each sub tree.