Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 50 additions & 17 deletions AGENTS.md

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ My personal dotfiles, managed with [chezmoi](https://www.chezmoi.io/).

## Install

### Linux (Debian/Ubuntu/Arch) — dev containers, WSL, cloud VMs
### Linux (Debian/Ubuntu/Arch/Omarchy) — dev containers, WSL, cloud VMs

Clone and run the bootstrap script. It installs mise, chezmoi, fish, Claude
Code, Codex, Antigravity CLI, GitHub Copilot CLI, and opencode, then applies the
dotfiles:
dotfiles. On [Omarchy](https://omarchy.org/) it installs through Omarchy's own
commands instead, keeps bash as the shell, and leaves the coding-agent CLIs that
Omarchy already provides to Omarchy:

```sh
git clone https://github.com/CS-5/dotfiles.git ~/.local/share/chezmoi
Expand Down Expand Up @@ -43,16 +45,17 @@ iex "&{$(irm 'https://get.chezmoi.io/ps1')} init --apply CS-5"

## Commit signing

Commits are signed with an SSH key, picked at `chezmoi init` time:
Commits are signed with the "GitHub Signing" SSH key stored in Bitwarden, whose
public key is inlined in the git config. git signs only through an SSH agent
that holds it: Bitwarden's own, the host's agent forwarded into a dev container,
or the Windows-side Bitwarden agent on WSL. Nothing is kept on disk; Bitwarden
must be running and unlocked to commit, and without it commits fail.

1. On work machines where Bitwarden is the SSH agent, and in dev containers
(which use the host's forwarded agent), git signs through Bitwarden with the
"GitHub Signing" key stored in the vault. Nothing is kept on disk; Bitwarden
must be running and unlocked to commit.
2. Otherwise, if `~/.ssh/git_signing` exists, git signs directly from that file
(no agent needed). `install.sh` generates one on Linux hosts without a
Bitwarden agent, except WSL.
3. Otherwise, commits are not signed.
On a headless box, connect with agent forwarding (`ssh -A`, or VS Code
Remote-SSH) so it signs through Bitwarden on the machine you connect from. A
box that commits while nobody is connected (e.g. a coding agent in a zellij
session) needs its own choice in `~/.config/local/gitconfig`: a signing key
just for that box, or `gpgSign = false` under `[commit]` and `[tag]`.

Signing is always disabled in Codespaces (GitHub signs those server-side).

Expand All @@ -62,3 +65,9 @@ On macOS, the dotfiles configure [Brouter](https://github.com/CS-5/Brouter) at
`~/.config/brouter/config.toml`. Install the app yourself from its
[releases](https://github.com/CS-5/Brouter/releases) and let it become the
default browser. The routing rules are described in `AGENTS.md`.

## Per-machine overrides

Anything that should apply to one machine only goes in `~/.config/local/`,
which the dotfiles never touch: `shell.sh` (bash/zsh), `shell.fish`,
`gitconfig`, and `hypr.lua` (Omarchy). Each is loaded last, if it exists.
106 changes: 72 additions & 34 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ SCRIPT_DIR="$DOTFILES_SOURCE_DIR/scripts"

source "$SCRIPT_DIR/lib.sh"

# Omarchy installs and updates packages through its own entrypoints (a libalpm
# hook aborts a direct `pacman -Syu`) and keeps bash as the shell.
IS_OMARCHY=false
if [[ -r /etc/os-release ]] && grep -qx 'ID=omarchy' /etc/os-release; then
IS_OMARCHY=true
fi

# Omarchy's mise config provides most coding-agent CLIs itself (and keeps them
# current), unless this user opted out of Omarchy's default tools.
omarchy_provides() {
[[ "$IS_OMARCHY" == "true" ]] && command -v omarchy-mise-default-tools >/dev/null 2>&1 &&
omarchy-mise-default-tools declares "$1"
}

while [[ $# -gt 0 ]]; do
case $1 in
--work-email)
Expand All @@ -51,7 +65,10 @@ while [[ $# -gt 0 ]]; do
esac
done

mkdir -p ~/.local/bin ~/.config/fish/{conf.d,completions}
mkdir -p ~/.local/bin
if [[ "$IS_OMARCHY" != "true" ]]; then
mkdir -p ~/.config/fish/{conf.d,completions}
fi

log_info "Setting up environment${WORK_EMAIL:+ (work email: $WORK_EMAIL)}"

Expand All @@ -61,7 +78,12 @@ export PATH="$HOME/.local/bin:$PATH"
show_progress "Installing bootstrap dependencies"
# Same package names in Debian/Ubuntu and Arch repos.
BOOTSTRAP_PKGS=(curl git wget unzip gnupg fish neovim)
if command -v apt-get >/dev/null 2>&1; then
if [[ "$IS_OMARCHY" == "true" ]]; then
# No fish (bash is the shell here). chezmoi comes from the Arch repos rather
# than its curl installer, so `omarchy update` keeps it current.
# `omarchy pkg add` installs only what is missing, without a -Syu.
omarchy pkg add curl git wget unzip gnupg neovim chezmoi
elif command -v apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y "${BOOTSTRAP_PKGS[@]}"
elif command -v pacman >/dev/null 2>&1; then
Expand Down Expand Up @@ -101,54 +123,70 @@ else
fi
log_success "Dotfiles installed and applied"

#### Signing Key ####
# The rendered chezmoi config decides whether this host signs from a key file
# (no Bitwarden agent, not a dev container or WSL), so this runs after init.
# A newly generated key is only detected at render time, hence the re-init.
if [[ "$(chezmoi execute-template '{{ .signingKeyFileWanted }}')" == "true" && ! -f "$HOME/.ssh/git_signing" ]]; then
show_progress "Generating commit signing key"
"$SCRIPT_DIR/generate-signing-key.sh"
chezmoi init --apply --error-on-conflict --source="$DOTFILES_SOURCE_DIR"
log_success "Signing key generated and applied"
fi

#### Shell ####
show_progress "Setting up shell"
fish -c "fundle install"
if [[ "${SHELL:-}" != *"fish"* ]]; then
log_info "Changing default shell to fish"
sudo chsh -s "$(which fish)" "${USER:-$(id -un)}"
# Omarchy keeps bash: its own ~/.bashrc layering is what the dotfiles extend.
if [[ "$IS_OMARCHY" != "true" ]]; then
show_progress "Setting up shell"
fish -c "fundle install"
if [[ "${SHELL:-}" != *"fish"* ]]; then
log_info "Changing default shell to fish"
sudo chsh -s "$(which fish)" "${USER:-$(id -un)}"
fi
log_success "Shell setup complete"
fi
log_success "Shell setup complete"

#### Coding-agent CLIs ####
# Each with its vendor's installer, so it can self-update (see `update`),
# except where Omarchy's mise config already provides it.

#### Claude Code ####
show_progress "Installing Claude Code"
curl -fsSL https://claude.ai/install.sh | bash
log_success "Claude Code installed"
if omarchy_provides claude; then
log_info "Claude Code is provided by Omarchy"
else
show_progress "Installing Claude Code"
curl -fsSL https://claude.ai/install.sh | bash
log_success "Claude Code installed"
fi

#### Codex ####
# CODEX_NON_INTERACTIVE: the installer otherwise offers to launch codex via
# /dev/tty, which would stall an unattended bootstrap.
show_progress "Installing Codex"
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh
log_success "Codex installed"
if omarchy_provides codex; then
log_info "Codex is provided by Omarchy"
else
show_progress "Installing Codex"
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh
log_success "Codex installed"
fi

#### Antigravity CLI ####
show_progress "Installing Antigravity CLI"
curl -fsSL https://antigravity.google/cli/install.sh | bash
log_success "Antigravity CLI installed"
if omarchy_provides antigravity-cli; then
log_info "Antigravity CLI is provided by Omarchy"
else
show_progress "Installing Antigravity CLI"
curl -fsSL https://antigravity.google/cli/install.sh | bash
log_success "Antigravity CLI installed"
fi

#### GitHub Copilot CLI ####
# PREFIX pins ~/.local/bin; the installer would pick /usr/local when run as root.
show_progress "Installing GitHub Copilot CLI"
curl -fsSL https://gh.io/copilot-install | PREFIX="$HOME/.local" bash
log_success "GitHub Copilot CLI installed"
if omarchy_provides copilot; then
log_info "GitHub Copilot CLI is provided by Omarchy"
else
show_progress "Installing GitHub Copilot CLI"
curl -fsSL https://gh.io/copilot-install | PREFIX="$HOME/.local" bash
log_success "GitHub Copilot CLI installed"
fi

#### opencode ####
# --no-modify-path: the installer would otherwise append to chezmoi-managed
# shell configs, which already put ~/.opencode/bin on PATH.
show_progress "Installing opencode"
curl -fsSL https://opencode.ai/v2/install | bash -s -- --no-modify-path
log_success "opencode installed"
if omarchy_provides opencode; then
log_info "opencode is provided by Omarchy"
else
show_progress "Installing opencode"
curl -fsSL https://opencode.ai/v2/install | bash -s -- --no-modify-path
log_success "opencode installed"
fi

log_success "Setup complete"
3 changes: 1 addition & 2 deletions render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# home, this script points the file check at a nonexistent temp path (via
# DOTFILES_WORK_EMAIL_FILE) and supplies the email through the env var, so
# the template's real detection logic (env fallback + domain mapping) runs
# (HOME is left intact, so signing-key and other homeDir-derived paths stay
# faithful to the host).
# (HOME is left intact, so homeDir-derived paths stay faithful to the host).
#
# Usage: ./render.sh [--identity IDENTITY] [--work-email <addr>] [--dc] [--codespaces] [--data <json>] <template-file>

Expand Down
57 changes: 22 additions & 35 deletions root/.chezmoi.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ sourceDir = {{ env "DOTFILES_SOURCE_DIR" | default "~/.local/share/chezmoi" | qu
{{ $probablyDc := or (env "REMOTE_CONTAINERS_IPC" | not | not) (eq (env "USER") "vscode") (stat "/workspaces" | not | not) -}}
{{ $isCodespaces := env "CODESPACES" | not | not -}}
{{ $isDc := or $probablyDc $isCodespaces -}}
{{/* Keyed on the distro ID rather than a path, so it is false by
construction on WSL (ID=arch/ubuntu), dev containers, macOS and Windows. */}}
{{ $isOmarchy := eq (dig "osRelease" "id" "" .chezmoi) "omarchy" -}}
{{ $binDir := ".local/bin" -}}

{{/* Work identity is driven by ~/work.email: a file whose sole contents
are one work email address. When the file is absent, the
DOTFILES_WORK_EMAIL env var is consulted as a fallback (Codespaces
user secrets surface as env vars). The email's domain selects the
identity; no email or an unrecognized domain means personal. Mirrors
the per-host signing-key file below. Add new jobs to $identities. */}}
identity; no email or an unrecognized domain means personal. Add new
jobs to $identities. */}}
{{ $identities := dict
"kirbtech.com" "kirbtech"
"journalytic.com" "journalytic" -}}
Expand All @@ -34,14 +37,15 @@ sourceDir = {{ env "DOTFILES_SOURCE_DIR" | default "~/.local/share/chezmoi" | qu
{{ end -}}
{{ $isWork := ne $identity "personal" -}}

{{/* Work machines use the Bitwarden desktop app as their only SSH agent.
Dev containers use the host's forwarded agent instead, and on WSL the
app runs on the Windows side where its Unix socket is unreachable.
Sandboxed installs (App Store, snap, flatpak) put the socket inside
their container, so candidates are checked in order at runtime; the
last entry, the native install path, is the fallback. */}}
{{/* The Bitwarden desktop app is the only SSH agent, reached directly or
forwarded into an SSH session (ssh -A), which is how a headless box
reaches it. Dev containers use the host's forwarded agent instead, and
on WSL the app runs on the Windows side where its Unix socket is
unreachable. Sandboxed
installs (App Store, snap, flatpak) put the socket inside their
container, so candidates are checked in order at runtime; the last
entry, the native install path, is the fallback. */}}
{{ $isWsl := env "WSL_DISTRO_NAME" | not | not -}}
{{ $bitwardenSshAgent := and $isWork (not $isDc) (not $isWsl) (ne .chezmoi.os "windows") -}}
{{ $bitwardenSshSocks := list -}}
{{ if eq .chezmoi.os "darwin" -}}
{{ $bitwardenSshSocks = append $bitwardenSshSocks (joinPath .chezmoi.homeDir "Library/Containers/com.bitwarden.desktop/Data/.bitwarden-ssh-agent.sock") -}}
Expand All @@ -50,30 +54,14 @@ sourceDir = {{ env "DOTFILES_SOURCE_DIR" | default "~/.local/share/chezmoi" | qu
{{ $bitwardenSshSocks = append $bitwardenSshSocks (joinPath .chezmoi.homeDir ".var/app/com.bitwarden.desktop/data/.bitwarden-ssh-agent.sock") -}}
{{ end -}}
{{ $bitwardenSshSocks = append $bitwardenSshSocks (joinPath .chezmoi.homeDir ".bitwarden-ssh-agent.sock") -}}
{{ $bitwardenSshAgent := and (not $isDc) (not $isWsl) (ne .chezmoi.os "windows") -}}

{{/* Signing key, first match wins:
1. Bitwarden as the SSH agent, directly, forwarded into a dev container
from the host, or on the Windows side of WSL (reached through
ssh-keygen.exe): git signs through the agent with the "GitHub
Signing" key stored in the vault, so nothing lives on disk.
Any ~/.ssh/git_signing on these machines is ignored.
2. A private key on disk at ~/.ssh/git_signing: git signs from the
file, no agent. install.sh generates one where $signingKeyFileWanted.
3. Neither: commits are not signed. */}}
{{ $signingKey := "" -}}
{{ $signingKeyFile := "" -}}
{{ $signingKeyFilePath := joinPath .chezmoi.homeDir ".ssh/git_signing" -}}
{{ $signingKeyFileWanted := not (or $bitwardenSshAgent $isDc $isWsl) -}}
{{ if or $bitwardenSshAgent $isDc $isWsl -}}
{{ $signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGUhU31PFPWI9ggTCNK7JuYnc7O7RrUKgjjt2aWDCVIP" -}}
{{ else if stat $signingKeyFilePath -}}
{{ $signingKeyFile = $signingKeyFilePath -}}
{{ $signingPubKeyPath := printf "%s.pub" $signingKeyFilePath -}}
{{ if stat $signingPubKeyPath -}}{{ $signingKey = include $signingPubKeyPath | trim -}}{{ end -}}
{{ end -}}

{{/* Codespaces sign server-side with GitHub's own web-flow key. */}}
{{ $gitSign := and (not $isCodespaces) (or (ne $signingKeyFile "") (ne $signingKey "")) -}}
{{/* Commits are signed with the "GitHub Signing" key stored in Bitwarden,
always through an SSH agent: Bitwarden's own, the host's forwarded into
a dev container, or the Windows-side one on WSL (reached through
ssh-keygen.exe). Codespaces sign server-side with GitHub's own
web-flow key. */}}
{{ $gitSign := not $isCodespaces -}}

[data]
# Environment Info
Expand All @@ -85,6 +73,7 @@ sourceDir = {{ env "DOTFILES_SOURCE_DIR" | default "~/.local/share/chezmoi" | qu
isWindows = {{ eq .chezmoi.os "windows" }}
isWsl = {{ $isWsl }}
isDc = {{ $isDc }}
isOmarchy = {{ $isOmarchy }}

# Identity
identity = {{ $identity | quote }}
Expand All @@ -96,10 +85,8 @@ sourceDir = {{ env "DOTFILES_SOURCE_DIR" | default "~/.local/share/chezmoi" | qu
workEmail = {{ $workEmail | quote }}

# Signing
gitSigningPubKey = {{ $signingKey | quote }}
gitSigningKeyFile = {{ $signingKeyFile | quote }}
gitSigningPubKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGUhU31PFPWI9ggTCNK7JuYnc7O7RrUKgjjt2aWDCVIP"
gitSign = {{ $gitSign }}
signingKeyFileWanted = {{ $signingKeyFileWanted }}

# SSH agent
bitwardenSshAgent = {{ $bitwardenSshAgent }}
Expand Down
63 changes: 63 additions & 0 deletions root/.chezmoidata/omarchy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# What an Omarchy machine needs that isn't a file: packages, Omarchy's own
# installers, and third-party shell plugins. Source-only (under .chezmoidata/
# this is template data, never a file in $HOME), consumed by
# .chezmoiscripts/run_after_08-omarchy-packages.sh.tmpl.
#
# To add something, add an entry. This says what must be present, not what
# must be absent: deleting an entry never uninstalls anything.

[omarchy]

# Arch and Omarchy repo packages, installed with `omarchy pkg add`.
packages = ["bitwarden", "efibootmgr", "fwupd", "usbutils"]

# AUR packages, installed with `omarchy pkg aur add`.
aur = ["hyprmoncfg"]

# Omarchy's installers do more than install a package (set the app as the
# Omarchy default, wire it into the theme system, ...), so they are preferred
# whenever one exists. `package` is the sentinel: the installer runs only while
# that package is missing.
[[omarchy.installers]]
command = "terminal ghostty"
package = "ghostty"

[[omarchy.installers]]
command = "editor vscode"
package = "visual-studio-code-bin"

[[omarchy.installers]]
command = "editor zed"
package = "zed"

[[omarchy.installers]]
command = "browser chrome"
package = "google-chrome"

[[omarchy.installers]]
command = "ai claude"
package = "claude-desktop"

# Third-party Omarchy shell plugins, cloned into ~/.config/omarchy/plugins.
# Only installed, never enabled: shell.json is yours, so place each one once
# per machine with `omarchy plugin enable <id>`. `omarchy plugin update` keeps
# them current.
[[omarchy.plugins]]
id = "bobbynicholas.omaland"
url = "https://github.com/bobby-nicholas/omaland.git"

[[omarchy.plugins]]
id = "crmne.hyprmoncfg"
url = "https://github.com/crmne/omarchy-hyprmoncfg.git"

[[omarchy.plugins]]
id = "io.github.sirjul1337.lock-explorer"
url = "https://github.com/SirJul1337/omarchy-lock-explorer.git"

[[omarchy.plugins]]
id = "jkoestinger.vpn"
url = "https://github.com/jkoestinger/omarchy-vpn.git"

[[omarchy.plugins]]
id = "io.github.cyprusad.omakeez"
url = "https://github.com/cyprusad/omakeez.git"
Loading