How I Set Up My Environment
I have several devices, including MacBooks, mini PCs, Raspberry Pis, and Linux servers. I want to keep my environment consistent across all of them so I can easily start my job from any device, especially when setting up a new machine from scratch.
Here is how I set up my environment.
Overview
Dotfiles
I track all my configuration files using Chezmoi and sync them to a public repository on GitHub.
So every time I make changes to my configuration files, I run chezmoi add FILE
to my dotfiles repo. Then on other machines I run chezmoi update
to get the latest updates.
I didn’t automate this process because configuration updates are not frequent, and it’s totally acceptable to run a command when I notice there is an update.
It is a great convenience that I only need one command to set up all my configurations on a new machine.
Cross-Platform Apps
I use many tools every day, and most of them are cross-platform. This way, I don’t have to experience a change in behavior when I switch to a different machine.
However, each platform has its own method for installing apps, which requires me to set up my tools differently. For instance, I use Homebrew on macOS, and both Flatpak and DNF on Fedora. They may have different versions since the latest available version depends on the package manager.
Foretunately, most of the tools I use are open source and can be downloaded directly from GitHub, such as Chezmoi, NeoVim, Zoxide, Ripgrep, etc.
I tried to build a tool to download such apps from GitHub on any platform, but I failed to maintain it because adding each application manually is troublesome. It would be much better if there were a community to maintain it, like what is done for Homebrew.
Then I found Mise, which is super easy to use, and also supports different platforms. I just need to run a simple command mise up
to keep all my tools up-to-date. Wow!
So, my current workflow involves managing frequently used cross-platform tools with Mise, while still using platform-specific package managers like Homebrew or Flatpak for other GUI or non-cross-platform applications.
Encrypted Data
Besides the configuration maintained by Chezmoi, there is other data that should not be contained in a public repository, such as private keys and configurations that include private tokens.
Chezmoi supports encryption, so I encrypt private configurations and store them in my dotfiles.
For data that isn’t configuration or isn’t suitable for dotfiles, I use Gopass to encrypt it and store it in a different repository. Keeping dotfiles separate from other private data is a good idea because I always set up dotfiles on all devices, but I only install the private data on trusted personal devices.
My encrypted data in both dotfiles and Gopass stores is encrypted using Age, a simple, secure, and user-friendly encryption tool. Therefore, I need to keep my private keys safe and always accessible.
My solution is to store the super confidential and rarely used data like private keys in a local KDBX database and upload it to public cloud services, my blog, and other places that can be accessed directly without depending on any of my devices.
Steps for Setting Up
That’s all the details about my environment setup. Here are the steps for setting everything up on a new machine:
- Install Mise
- Install all the command-line tools I need using Mise
- Optionally on my trusted personal devices
- Get my KDBX database and unlock it using the method no one else knows
- Get my Age key from the KDBX database
- Set up Gopass stores
- Set up dotfiles using Chezmoi
Everything is ready after just a few lines of commands.