# One dotfiles repo for macOS and a Linux VPS

> How one chezmoi repo sets up a Mac and my Linux machines the same way: templates, apply-time scripts, packages, secrets, themes and sync.

- Author: James Hong
- Published: 2025-06-24
- Tags: dotfiles, linux, macos, productivity
- URL: https://gnohj.net/blog/one-dotfiles-repo/

Everything I work in is configured from one Git repository.
It has been going since October 2024, and it now manages 686 files across a Mac and my Linux machines.
This post is a tour of how it is put together and the rules that keep it from falling apart.

## Why one repo

I work on a MacBook, and I run long jobs on a headless Linux box.
For a while those were two setups that slowly drifted apart.
A keybinding would exist on one and not the other, and I would only find out mid-task.

One repo fixes that by making drift visible.
If the two machines differ, it is because a file says so, not because I forgot.

## What is in it

The repo covers the whole working environment, not only shell config.

| Area          | Shared                                                                                                                                    | macOS only                                                                                                                                                     | Linux only                                                        |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| Shell         | [zsh](https://www.zsh.org/), [Starship](https://starship.rs/), [Atuin](https://atuin.sh/)                                                 |                                                                                                                                                                |                                                                   |
| Editor        | [Neovim](https://neovim.io/)                                                                                                              |                                                                                                                                                                |                                                                   |
| Terminal      | Rex                                                                                                                                       | [Ghostty](https://ghostty.org/), [Kitty](https://sw.kovidgoyal.net/kitty/)                                                                                     |                                                                   |
| Files and Git | [Yazi](https://github.com/sxyazi/yazi), [Lazygit](https://github.com/jesseduffield/lazygit), [Delta](https://github.com/dandavison/delta) |                                                                                                                                                                |                                                                   |
| Tool versions | mise                                                                                                                                      | [nix-darwin](https://github.com/nix-darwin/nix-darwin), [Homebrew](https://brew.sh/)                                                                           | [Omarchy](https://omarchy.org/) on [Arch](https://archlinux.org/) |
| Windows       |                                                                                                                                           | [Rift](https://github.com/acsandmann/rift), [JankyBorders](https://github.com/FelixKratz/JankyBorders), [Sketchybar](https://github.com/FelixKratz/SketchyBar) | [Hyprland](https://hyprland.org/)                                 |
| Keys          |                                                                                                                                           | [skhd](https://github.com/koekeishiya/skhd), [Kanata](https://github.com/jtroo/kanata)                                                                         |                                                                   |
| Networking    | [Tailscale](https://tailscale.com/)                                                                                                       |                                                                                                                                                                |                                                                   |
| Secrets       |                                                                                                                                           | [Bitwarden](https://bitwarden.com/) through [rbw](https://github.com/doy/rbw)                                                                                  |                                                                   |

There are 54 folders under `~/.config` alone, and the Neovim config is 58 plugin files.

## How chezmoi fits

[chezmoi](https://www.chezmoi.io/) keeps a source directory, and applies it to your home directory.
The source is the repo.
The targets are the real files, such as `~/.config/nvim`.

The file names in the source carry instructions:

- `dot_zshenv` becomes `~/.zshenv`.
- `executable_` marks a script as runnable.
- `private_` restricts permissions, which is what the SSH folder uses.
- `.tmpl` means the file is a template, rendered per machine.

The one rule that matters: edit the source, never the target.
A change made directly in `~/.config` is overwritten by the next `chezmoi apply`.

## Two operating systems, one set of files

Most files are identical on both systems.
Where they differ, there are two tools, and I reach for them in this order.

**Ignore the file.**
A config that only makes sense on one system is listed in `.chezmoiignore` for the other.
Sketchybar never lands on Linux, and Hyprland never lands on the Mac.
That file is 223 lines long.

**Template the difference.**
A file that is mostly shared stays one file, with a check around the lines that differ.
Only 12 files in the whole repo need this.

```text
~/Developer/gnohj-monorepo
{{- if eq .chezmoi.os "darwin" }}
~/Obsidian/second-brain
{{- end }}
~/Developer/agents
```

That is the list of repos my sync job pushes.
The notes vault only exists on the Mac, so it is wrapped in a check, and the rest is shared.

I template the difference and not the file.
Two near-identical copies of a config are the drift I was trying to get rid of.

## Scripts that run on apply

Some setup is not a file.
A background service has to be enabled, a helper has to be compiled, a package list has to be installed.

chezmoi runs scripts during apply, and the name says when:

- `run_once_` runs a single time per machine.
- `run_onchange_` runs again whenever its contents change.
- `run_after_` runs after the files are in place.

Most of mine are `run_onchange_` scripts that enable a service.
Because the script re-runs only when it changes, editing a service definition is enough to reload it, and an ordinary apply does nothing.

## Packages and tool versions

Packages are the part that differs most between systems, so each system uses what suits it.

- **macOS:** nix-darwin manages system settings, and Homebrew installs apps.
- **Linux:** Omarchy on Arch brings its own base.
- **Both:** [mise](https://mise.jdx.dev/) pins language and CLI versions, so `node` and `python` match everywhere.

Global tools installed through [Bun](https://bun.sh/) and [Cargo](https://doc.rust-lang.org/cargo/) are plain text lists in the repo.
A script installs whatever is on the list, so adding a tool is one line.

## Secrets

No secret is committed.
The repo is public, so this is not optional.

Credentials live in Bitwarden, and `rbw` reads them at the moment a command needs one.
Anything machine-specific that should not be public, such as a server address, comes from a local file that the repo ignores.

## One colorscheme for everything

A scheme is a small file of named colours, and a symlink marks the active one.
One command switches it, and regenerates the config for every tool that has colours.

That is 20 outputs today, including the terminals, Neovim, the prompt, Lazygit, Yazi, [bat](https://github.com/sharkdp/bat), Delta, [btop](https://github.com/aristocratos/btop), window borders and the status bar.
The wallpaper changes with it.

Numbered colour slots turned out to be a trap, because one slot ended up serving as both blue and body text.
So there are named roles on top: text, muted text, selection and accent.
A tool asks for the role it needs.

This site is one of the readers.
I wrote about that in [This site wears my desktop theme](/blog/site-wears-my-desktop-theme/).

## Keeping machines in sync

A timer commits and pushes a list of repos, and pulls before it pushes.
Notes and agent config move between machines that way, without my thinking about it.

The dotfiles repo itself is deliberately not on that list.
Config changes get real commit messages, pushed by hand, because I want to be able to read the history later.
There are 3,318 commits so far.

## Starting from a new machine

A new machine takes one script per system, `mac-setup.sh` or `linux-vps-setup.sh`, followed by a shared `user-setup.sh`.
They install the package manager and chezmoi, clone the repos I work in, and run the first apply.

A few steps cannot be scripted, such as granting accessibility permissions on macOS.
Those are written down in a manual checklist in the repo, so that the next setup does not depend on my memory.

## Rules that keep it working

These are the habits that have saved me the most time.

1. **Edit the source, never the target.** Anything else is lost on the next apply.
2. **Check shared files on both systems before committing.** A change that works on the Mac can break a shell that starts under a different init system.
3. **Prefer ignoring a file to templating it.** A template is harder to read than a file that simply is not there.
4. **Let scripts be re-runnable.** An apply should be safe to run twice in a row.
5. **Write down what cannot be automated.** A checklist beats a clever script that works once.

## What it costs

It is not free.
A setup like this is software, and software needs maintenance.
An operating system update can break the status bar, and a tool can change its config format.

I think it is worth it.
A new machine is usable in an afternoon, and both machines behave the same way under my hands.
The source is at [github.com/gnohj/dotfiles](https://github.com/gnohj/dotfiles).
