Help me understand the workflow for cloning dotfiles after a fresh install without hosting dotfiles in the cloud

https://lemmy.ml/post/41657723

Help me understand the workflow for cloning dotfiles after a fresh install without hosting dotfiles in the cloud - Lemmy

I’ve been reading up on the concept of dotfile management, and I’ve come across tools such as GNU Stow, chezmoi, and yadm, but before I select a tool, I’d like to understand the workflow a little better. I understand if the dotfiles are in some cloud provider such as GitHub, then after a fresh install one can do git clone etc, but let’s say one’s dotfiles are not stored in the cloud, then what’s the workflow for getting those dotfiles onto the freshly installed OS? Do people do git clone from another machine on their local network, manually copy the dotfiles folder from the source, use an app like LocalSend, or something else?

let’s say one’s dotfiles are not stored in the cloud, then what’s the workflow for getting those dotfiles onto the freshly installed OS?

@yo_scottie_oh this is exactly what I do. I keep an always up-to-date Git repo on my old desktop PC which is always on and acts as a file server. My laptops and cell phone all connect to it over a WiFi router.

After you copy your dotfiles repo to your file server, make sure the head of the main branch is detached, or it may not let you push from a remote, since Git thinks you are going to overwrite the branch that someone is using.

The first step when I get a new computer is to install SSH, then I use scp or rsync to copy my offline Git repo from my file server to my new computer from another computer that has an up-to-date clone. Then I use the git remote command to change the remote to the file server’s IP address, e.g. git remote add 'my-file-server' [email protected]:/home/mylogin/git/dotfiles.

The file server itself does not have a remote setup, but it might be set to an old branch, so make sure you check out the most recent branch from the last computer you used to push to it: git checkout dead-laptop/main.

After that, you can use your local clone which you copied with rsync as any ordinary Git repo, but it will push to the remote (the file server).

Also, it helps to run ssh-agent and create a new ECDSA key, copy it to the file server with ssh-copy-id, otherwise Git will ask you for you password every time you push.

@[email protected]

Lemmy - A community of privacy and FOSS enthusiasts, run by Lemmy’s developers

Lemmy

i host my dotfiles on GitHub, but any cloud provider or self-hosted git instance will do. otherwise, rsync, scp, or a good old fashioned thumb drive

You know you can just use git directly, right? That’s kinda its whole point, that it’s a self-contained topl for source distribution.

You can laterally just git pull from any machine through SSH…

I’ve been happy with GNU Stow. Super simple and clean. I keep all the files in ~/stow and follow this workflow. You can avoid the git bits if you want and update ~/stow however you want.

cd ~/stow # pull latest changes from git provider for syncing git fetch git status git pull # if made any edits and wanted to push them git add . git push origin main # do a dry run of stow just to make sure it won't do anything weird stow -n -v --no-folding . # do a real run of stow if nothing is wrong # note: --no-folding prevents folders from becoming symlinked, only files will be symlinks, # this prevents unintended files from going into ~/stow stow -v --no-folding .
Thanks for sharing your workflow. How often do you use this workflow? And are you more often cloning your dotfiles for a new setup or just keeping them updated across existing setups over time?

I use it pretty often to keep my desktop, laptop, and server configs in sync.

To setup new systems, I created this bash script: lemmy.world/post/41584520/21545156

Then I would run the commands in my original post to create the symlinks.

Help me understand the workflow for cloning dotfiles after a fresh install without hosting dotfiles in the cloud - Lemmy.World

I’ve been reading up on the concept of dotfile management, and I’ve come across tools such as GNU Stow, chezmoi, and yadm, but before I select a tool, I’d like to understand the workflow a little better. I understand if the dotfiles are in some cloud provider such as GitHub, then after a fresh install one can do git clone etc, but let’s say one’s dotfiles are not stored in the cloud, then what’s the workflow for getting those dotfiles onto the freshly installed OS? Do people do git clone from another machine on their local network, manually copy the dotfiles folder from the source, use an app like LocalSend, or something else? EDIT: Clarifying that this is for a home environment, where I have two or three different laptops in service at any given time. One is my main daily driver and doesn’t change much. The other two are kinda my sandboxes and I’m often distro hopping on them. This question is mostly for distro hopping on my sandboxes, which is like once or twice a month. Thanks!

You could self-host a shared “source of truth” git repo that you access over ssh. That can be anything from a USB thumb drive, a small clean server or a container on your existing desktop with ssh access, to an entire Forgejo deployment. Then you only need the “secret zero” of an ssh key to get everything set up and syncable.

If fresh setup is more common, you probably have other parts like package installation and network configuration that you also want to automate. Enter configuration management like ansible or salt, image builders like packer or archiso, “immutable” solutions like Nix or rpm-ostree. Once you get there you typically manage that in git anyway and you could put your dotfiles repo as a submodule and copy them over as part of OS setup.

If it’s just for once in a blue moon, manual ad-hoc copying gets you pretty far.

No matter how you slice it I think you have to either frequently spend time syncing changes or just accept the drift and divergence between machines and the sources.

Then you only need the “secret zero” of an ssh key to get everything set up and syncable

I made a script just for this purpose, I run the script on a fresh system and it pulls my stow directory without me needing to manually mess with ssh keys or passwords.

On a flashdrive, I have a folder named “setup”. In that folder, I have this script called “run” and a directory called “ssh”. In that “ssh” folder (not to be confused with ~/.ssh), I put my private ssh keys and their pubs.

#!/bin/bash # stop script immediately on error set -e # change working directory to directory containing this script cd "$(dirname "$0")" # check that ./ssh exists and exit if not if [ ! -d ./ssh ]; then echo "./ssh not detected, exiting..." exit 1 fi # create .ssh directory [ ! -d $HOME/.ssh ] && mkdir $HOME/.ssh chmod 700 $HOME/.ssh # copy keys to ~/.ssh cp -a ./.ssh/. $HOME/.ssh/ # ensure right permissions for .ssh contents # note: 2>/dev/null suppresses errors if no .pub files exist, || true to avoid exiting on failure chmod 600 $HOME/.ssh/* chmod 644 $HOME/.ssh/*.pub 2>/dev/null || true # start ssh agent eval `ssh-agent -s` trap "ssh-agent -k" EXIT # add keys ssh-add "$HOME/.ssh/privatesshkey" # add known hosts # note: removing them first then adding again to avoid duplicate entries ssh-keygen -R codeberg.org 2>/dev/null || true ssh-keygen -R github.com 2>/dev/null || true ssh-keyscan -H codeberg.org >> $HOME/.ssh/known_hosts ssh-keyscan -H github.com >> $HOME/.ssh/known_hosts # clone repo cd $HOME if [ -d "$HOME/stow" ]; then TIMESTAMP=$(date +"%Y%m%d_%H%M%S") mv "$HOME/stow" "$HOME/stow.old.$TIMESTAMP" fi git clone ssh://[email protected]/myusername/stow.git

So, I have been wondering how distro hoppers handle setting up the system after an install… Going by this thread, it sounds like it is just a matter of stashing the config files somewhere else and then restoring them afterwards?

What about applications? I assume those need to be reinstalled and configs restored as well, or is it all manual after getting the OS set up?

One last question, does anyone have a link to an article explaining the process?