Skip to content
Closed
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
1 change: 1 addition & 0 deletions .chezmoiroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
home
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ just add-machine NAME # Onboard + bootstrap an already-reachable machine via S
- `kube` fetches `~/.kube/config` + `~/.talos/config` from Bitwarden — desktops only.
- `ssh_keys` round-trips per-machine ed25519 keys through Bitwarden, building cross-machine `authorized_keys`.

After the playbook, `just apply*` runs bash **units** (`units/`, via mise through `scripts/run-units.sh`; see [`docs/src/units.md`](docs/src/units.md)): `omp`, `chezmoi`, `atuin`, `shell-ai`. `home/` is the chezmoi source for shell, git, neovim and atuin config; `ssh_keys` remains an Ansible role.

Roles are conditional on inventory group (`desktop`, `server`, `vps`, `test_fleet`, `termux_hosts`; `llm` is dormant/commented out) and on `skip_*` flags / `machine_profile` in `host_vars/`. See [`docs/src/roles/`](docs/src/roles/) for the full reference.

## Kubeconfig + Talos secrets
Expand Down
3 changes: 2 additions & 1 deletion CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

## Playbook

- **Role** — an Ansible role that configures one concern (e.g. `shell_dotfiles`, `tailscale`, `proxy`). The interface is `tasks/main.yml`; the implementation is templates, files, and handlers.
- **Role** — an Ansible role that configures one concern (e.g. `tailscale`, `proxy`, `ssh_keys`). The interface is `tasks/main.yml`; the implementation is templates, files, and handlers.
- **Unit** — an idempotent bash script in `units/` run in parallel by mise after the playbook (`omp`, `chezmoi`, `atuin`, `shell-ai`). A failing step does not stop the rest of the unit. See `docs/src/units.md`.
- **Phase** — a logical grouping of roles in `site.yml` (Phase 1: system + packages, Phase 2: secrets + auth, Phase 3: desktop, Phase 4: services). Phases are documented in comments, not enforced by the playbook.
- **Tag** — an Ansible tag applied to roles so `just apply-tags <tag>` can target a subset.

Expand Down
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ doctor:
echo "→ Machine identity"
if [ -f /etc/dotfiles-machine ]; then pass "machine: $(cat /etc/dotfiles-machine)"; else warn "/etc/dotfiles-machine missing — run bootstrap"; fi
echo "→ Core binaries"
for bin in brew bw gh tailscale ansible-playbook just mise; do
for bin in brew bw gh tailscale ansible-playbook just mise chezmoi; do
if command -v "$bin" >/dev/null 2>&1; then pass "$bin"; else warn "$bin missing"; fi
done
echo "→ Tailscale"
Expand Down
12 changes: 6 additions & 6 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
## Dotfiles

- [shell_fonts](roles/shell_fonts.md)
- [shell_dotfiles](roles/shell_dotfiles.md)
- [shell_atuin](roles/shell_atuin.md)
- [shell_ai](roles/shell_ai.md)
- [omp](roles/omp.md)
- [shell_dotfiles (chezmoi)](roles/shell_dotfiles.md)
- [shell_atuin (chezmoi + unit)](roles/shell_atuin.md)
- [shell_ai (unit)](roles/shell_ai.md)
- [omp (unit)](roles/omp.md)
- [hive_ops](roles/hive_ops.md)
- [git](roles/git.md)
- [neovim](roles/neovim.md)
- [git (chezmoi)](roles/git.md)
- [neovim (chezmoi)](roles/neovim.md)

## Secrets & Auth

Expand Down
9 changes: 3 additions & 6 deletions docs/src/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,8 @@ Every role in `site.yml` carries one or more tags. Tags fall into two kinds: **p
| System + packages | `termux_packages` | `system`, `packages`, `termux` |
| System + packages | `bitwarden` | `secrets`, `bitwarden` |
| System + packages | `shell_fonts` | `dotfiles`, `shell`, `fonts` |
| System + packages | `shell_dotfiles` | `dotfiles`, `shell`, `dotfiles` |
| System + packages | `omp` unit | `dotfiles`, `omp` |
| System + packages | `hive_ops` | `hive`, `hive_ops` |
| System + packages | `git` | `dotfiles`, `git` |
| System + packages | `neovim` | `dotfiles`, `neovim`, `editor` |
| Secrets + auth | `shell_atuin` | `dotfiles`, `shell`, `atuin`, `secrets` |
| Secrets + auth | `shell_ai` | `dotfiles`, `shell`, `ai`, `secrets` |
| Secrets + auth | `ssh_keys` | `secrets`, `ssh`, `ssh_keys` |
| Secrets + auth | `ssh_mesh` | `ssh`, `mesh_check` |
| Secrets + auth | `github` | `secrets`, `github` |
Expand All @@ -91,9 +86,11 @@ Every role in `site.yml` carries one or more tags. Tags fall into two kinds: **p
| Services | `server_hardening` | `system`, `hardening`, `security` |
| Services | `fleet_facts` | `facts`, `fleet_facts` |

Shell, git, neovim and atuin config, omp, and the shell/atuin secrets are not roles: they are [units](units.md) (`chezmoi`, `omp`, `atuin`, `shell-ai`) that `just apply*` runs after the playbook. The old tags `dotfiles`, `shell`, `git`, `neovim`, `editor`, `atuin`, `ai`, `secrets`, `omp` still select them through `scripts/run-units.sh`.

Common phase-wide selections:

- `--tags secrets` — every BW-backed role only (`bitwarden`, `shell_atuin`, `shell_ai`, `ssh_keys`, `github`, `tailscale`, `kube`, `forgejo_registry`)
- `--tags secrets` — every BW-backed role only (`bitwarden`, `ssh_keys`, `github`, `tailscale`, `kube`, `forgejo_registry`)
- `--tags desktop` — every desktop-app role (`flatpak`, `bluefin_common`, `gnome`, `zen_browser`, `pipewire_audio`)
- `--tags services` — every long-running service role (`syncthing`, `systemd`, `bst_dashboard`, `kirocrew`, `proxy`, `tailscale_cert`)
- `--skip-tags secrets` — everything except BW-backed roles. `just apply-nosecrets`, bootstrap's first phase and `phone-apply.service` also pass `--no-secrets` to units.
Expand Down
8 changes: 4 additions & 4 deletions docs/src/bitwarden.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ Every item a role or script reads (grep `bw get` / `bw list` under `roles/` and
| `talosconfig-aws-migration` | Secure Note | `kube` role — AWS cluster Talos config |
| `accounts.firefox.com` | Login + TOTP | `browser_fxa` role — Firefox Account credentials |
| `github-token` | Login (password) | `github` role — PAT for `gh auth login` |
| `atuin.sh` | Login + custom field `key` | `shell_atuin` role — atuin sync login + mnemonic |
| `deepseek-api-key` | Login (password) | `shell_ai` role — pi `auth.json` |
| `forgejo` | Secure Note (`API Token:` line) | `shell_ai` role — `FORGEJO_TOKEN` |
| `tavily-api-key` | Login (password) | `shell_ai` role — `TAVILY_API_KEY` |
| `atuin.sh` | Login + custom field `key` | `atuin` unit — atuin sync login + mnemonic |
| `deepseek-api-key` | Login (password) | `shell-ai` unit — pi `auth.json` |
| `forgejo` | Secure Note (`API Token:` line) | `shell-ai` unit — `FORGEJO_TOKEN` |
| `tavily-api-key` | Login (password) | `shell-ai` unit — `TAVILY_API_KEY` |
| `forgejo.manatee-basking.ts.net` | Login | `forgejo_registry` role — podman registry login |
| `bw-api-key` | Login | `scripts/bw-resolve.sh` — `bw login --apikey` on a remote |
| `James Bitwarden` | Login | `scripts/bw-resolve.sh` — non-interactive unlock on a remote |
Expand Down
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ The `llm` group is dormant (commented out in `inventory.yml`).

| Phase | Roles | Main tags |
|-------|-------|-----------|
| 1 — System + packages + dotfiles | sudo, sshd, apk_packages, homebrew, termux_packages, bitwarden, shell_fonts, shell_dotfiles, hive_ops, git, neovim | `system`, `packages`, `dotfiles` |
| 2 — Secrets + auth | shell_atuin, shell_ai, ssh_keys, ssh_mesh, github, tailscale, kube, forgejo_registry | `secrets` |
| 1 — System + packages + dotfiles | sudo, sshd, apk_packages, homebrew, termux_packages, bitwarden, shell_fonts, hive_ops | `system`, `packages`, `dotfiles` |
| 2 — Secrets + auth | ssh_keys, ssh_mesh, github, tailscale, kube, forgejo_registry | `secrets` |
| 3 — Desktop apps | flatpak, bluefin_common, gnome, zen_browser (+ browser_fxa), pipewire_audio | `desktop` |
| 4 — Services | syncthing, systemd, bst_dashboard, kirocrew, proxy, tailscale_cert, server_hardening | `services` |

The [`omp` unit](units.md) runs after Ansible, and can also use Bitwarden for its broker token. `just apply-nosecrets` skips the secret-tagged roles and passes `--no-secrets` to units.
After the playbook, `just apply*` runs the [bash units](units.md) (`chezmoi`, `omp`, `atuin`, `shell-ai`) in parallel through mise. The `omp` unit also uses Bitwarden for its broker token. `just apply-nosecrets` skips secret-tagged roles and passes `--no-secrets` to units.
18 changes: 9 additions & 9 deletions docs/src/roles/git.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# git

**Unit:** `chezmoi` (`units/chezmoi.sh`; see [Units](../units.md))
**Tags:** `dotfiles`, `git`
**Secrets needed:** No
**Runs on:** All machines
**Runs on:** All machines with `chezmoi` installed

Deploys Git configuration with SSH commit signing.
Git configuration with SSH commit signing, as chezmoi-managed files under `home/`:

## What It Does

1. Deploys `~/.gitconfig` with name, email, and signing preferences
2. Configures SSH commit signing using `~/.ssh/id_ed25519`
3. Deploys `~/.ssh/allowed_signers` for signature verification
4. Deploys GitHub CLI config at `~/.config/gh/config.yml`
| Target | Source |
|---|---|
| `~/.gitconfig` | `dot_gitconfig.tmpl` (data: `user_name`, `user_email`, `.chezmoi.homeDir`) |
| `~/.gitignore_global`, `~/.gitmessage` | `dot_gitignore_global`, `dot_gitmessage` |
| `~/.config/gh/config.yml` | `dot_config/gh/config.yml` |

## Key Settings

- **Signing:** SSH (`ssh-ed25519` key) for all commits
- **Allowed signers:** All fleet machine keys from Bitwarden
- **Allowed signers:** `~/.ssh/allowed_signers` is written by the `ssh_keys` role from the fleet machine keys in Bitwarden
- **Delta:** Git diff viewer (`git-delta`) for side-by-side diffs
11 changes: 3 additions & 8 deletions docs/src/roles/neovim.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# neovim

**Unit:** `chezmoi` (`units/chezmoi.sh`; see [Units](../units.md))
**Tags:** `dotfiles`, `neovim`, `editor`
**Secrets needed:** No
**Runs on:** All machines
**Runs on:** All machines with `chezmoi` installed

Deploys [Neovim](https://neovim.io/) configuration.

## What It Does

1. Creates `~/.config/nvim/` directory structure
2. Deploys init.lua and plugin configuration
3. Installs Lazy.nvim plugin manager and configured plugins
[Neovim](https://neovim.io/) configuration, deployed from `home/dot_config/nvim/` (`init.lua`, `lua/config/`, `lua/plugins/`) by chezmoi. `.chezmoiscripts/run_after_20-nvim-sync.sh` bootstraps lazy.nvim and runs `nvim --headless "+Lazy! sync" +qa` on first apply and when Lua configuration files are added, changed, or removed. It skips synchronization on unrelated applies; failures are best effort and retried on the next apply (300 s timeout, never fails the apply). The last successful fingerprint lives in `~/.cache/dotfiles/nvim-config.cksum`.

## Key Plugins

Expand Down
2 changes: 1 addition & 1 deletion docs/src/roles/omp.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The token is written only when Bitwarden is unlocked; a locked vault or `--no-se

To seed the token, run `just seed-omp-broker` on a client with the vault unlocked and SSH access to `ubuntu@100.113.75.88`. It reads the live token over SSH without rotating it and creates or updates the Bitwarden item. `OMP_AUTH_BROKER_SSH` overrides the SSH destination. Then run `just apply-tags omp` on each client and verify with `omp auth-broker status`. If the token is rotated on spindle, seed again and re-apply on the clients.

`DEEPSEEK_API_KEY` and the other provider keys are exposed to the shell by the `shell_ai` role's secret files, not by this unit.
`DEEPSEEK_API_KEY` and the other provider keys are exposed to the shell by the [`shell-ai` unit](shell_ai.md)'s secret files, not by this unit.

## Kiro authentication

Expand Down
29 changes: 19 additions & 10 deletions docs/src/roles/shell_ai.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# shell_ai

**Unit:** `shell-ai` (`units/shell-ai.sh`; see [Units](../units.md))
**Tags:** `dotfiles`, `shell`, `ai`, `secrets`
**Secrets needed:** Yes (`deepseek-api-key`, `forgejo`, `tavily-api-key`)
**Secrets needed:** Yes (`deepseek-api-key`, `forgejo`, `tavily-api-key`, `meta-api-key`, `kiro-api-key`)
**Runs on:** All machines

Deploys API credentials for the AI coding tools and shell.
Writes API credentials for the AI coding tools and shell.

## What It Does

1. When `bw_unlocked`:
- `bw get password deepseek-api-key` → `DEEPSEEK_API_KEY` in shell secret files
- `bw get notes forgejo` (the `API Token:` line) → `FORGEJO_TOKEN`
- `bw get password tavily-api-key` → `TAVILY_API_KEY`
- Writes these exports to `~/.config/shell/secrets.sh` (bash/zsh) and
`~/.config/fish/conf.d/secrets.fish` (fish), both 0600
2. Warns if `deepseek-api-key` is missing; Kiro OAuth remains a per-user OMP sign-in
With an unlocked vault (`bw_session`; never prompts):

- `bw get password deepseek-api-key` → `DEEPSEEK_API_KEY`
- `bw get notes forgejo` (the `API Token:` line) → `FORGEJO_TOKEN`
- `bw get password tavily-api-key` → `TAVILY_API_KEY`
- `bw get notes meta-api-key` → `META_API_KEY`
- `bw get notes kiro-api-key` → `KIRO_API_KEY`

The values present are written (single-quoted, 0600, via temp file + `mv`) to `~/.config/shell/secrets.sh` (bash/zsh; also exports `OMP_KIRO_CONFIG`) and `~/.config/fish/conf.d/secrets.fish` (fish; ends with a runtime Kiro key refresh from `/tmp/bw_session`).

## Output lines

- `SKIPPED: vault locked or --no-secrets` — files left untouched
- `warn: no secrets found in Bitwarden` — files left untouched

## Notes

- Not a chezmoi template on purpose: `bitwarden` template functions abort the whole template when one item is missing, while the unit writes whatever secrets exist.
- A locked vault leaves any previously written secret files untouched — nothing is overwritten with empty values
- `TAVILY_API_KEY` is read by the `tavily-search` skill deployed by the [`omp`](omp.md) role
- `TAVILY_API_KEY` is read by the `tavily-search` skill deployed by the [`omp`](omp.md) unit
27 changes: 16 additions & 11 deletions docs/src/roles/shell_atuin.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# shell_atuin

**Units:** `chezmoi` (config file), `atuin` (`units/atuin.sh`; see [Units](../units.md))
**Tags:** `dotfiles`, `shell`, `atuin`, `secrets`
**Secrets needed:** Yes, for login (`atuin.sh` from Bitwarden)
**Runs on:** All machines
Expand All @@ -8,18 +9,22 @@ Configures [Atuin](https://atuin.sh/) shell history and logs it in to sync.

## What It Does

1. Writes `~/.config/atuin/config.toml` — sync to `api.atuin.sh` every 5m,
fuzzy search, `filter_mode = "global"` (including the Up-arrow binding)
2. Checks `atuin status`; if already logged in, skips the Bitwarden round-trip
3. Otherwise, when `bw_unlocked`, reads the `atuin.sh` item (username,
password, and a custom field `key` holding the mnemonic) and runs
`atuin login -u … -p … -k …`
4. Runs a best-effort `atuin sync`
5. Imports existing shell history once (`atuin import auto`, sentinel
`~/.local/share/atuin/.history_imported`)
1. chezmoi writes `~/.config/atuin/config.toml` from `home/dot_config/atuin/config.toml` — sync to `api.atuin.sh` every 5m, fuzzy search, `filter_mode = "global"` (including the Up-arrow binding)
2. The `atuin` unit checks `atuin status`; if it shows `[Sync]` the Bitwarden round-trip is skipped
3. Otherwise, with an unlocked vault, it reads the `atuin.sh` item (username, password, custom field `key` holding the mnemonic). Atuin 18.24 or newer receives the password and key through its environment, not command-line arguments. The unit preserves the data directory and its history; a missing key can be written by Atuin during login. If a key already exists, the unit logs in only when `atuin key` matches the vault mnemonic, then runs a best-effort `atuin sync`.
4. Imports existing shell history once (`atuin import auto`, sentinel `~/.local/share/atuin/.history_imported`). If the version or existing key requires manual login, the unit also defers importing until that situation is resolved.

## Output lines

- `SKIPPED: atuin not installed` — install it (`core_brews`)
- `PARTIAL: atuin not logged in; vault locked` — `bw unlock`, then `just apply-tags atuin`
- `PARTIAL: Bitwarden item atuin.sh missing or incomplete` — fix the item (needs username, password, field `key`)
- `PARTIAL: atuin 18.24 or newer required` — upgrade Atuin or run `atuin login` interactively; older versions do not support the non-interactive environment credentials
- `PARTIAL: cannot determine the Atuin key path`, `cannot read the existing Atuin key`, or `existing Atuin key differs` — inspect the local data and resolve the key situation before logging in interactively. A vault key in a different representation can also compare unequal.

## Notes

- Skips login with a warning if the `atuin` binary is missing (it's in `core_brews`)
- The mnemonic is passed to `atuin login -k`, never written to `~/.local/share/atuin/key` directly — atuin expects that file to be a binary key
- Existing keys are never deleted or replaced by the unit; it does not reset `~/.local/share/atuin` when the key is missing. That directory is kept mode 0700, including after a prior history import.
- Atuin 18.24 resolves its own configured key path, including the newer `~/.atuin/data` layout; the history-import sentinel remains in `~/.local/share/atuin`.
- Alpine's community `atuin` package may be an older offline-only build; sync requires a sync-enabled Atuin client. Check the package version and features before attempting a manual login.
- Don't set the Up-arrow filter to `session`: it looks broken in fresh terminals
37 changes: 24 additions & 13 deletions docs/src/roles/shell_dotfiles.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# shell_dotfiles

**Tags:** `dotfiles`, `shell`
**Unit:** `chezmoi` (`units/chezmoi.sh`; see [Units](../units.md))
**Tags:** `dotfiles`, `shell` (`just apply-tags shell` runs `unit:chezmoi`)
**Secrets needed:** No
**Runs on:** All machines
**Runs on:** All machines with `chezmoi` installed (`core_brews`)

Deploys the shell, prompt, multiplexer and terminal configs.
No longer an Ansible role: the shell, prompt, multiplexer and terminal configs are chezmoi-managed files under `home/` (`.chezmoiroot` points chezmoi there).

## What It Does
## Files (source in `home/`)

1. `~/.config/shell/aliases.sh` (bash/zsh) and `~/.config/fish/conf.d/aliases.fish` — shared aliases, templated
2. `~/.bashrc`, `~/.zshrc`, `~/.zprofile` — templated
3. `~/.config/fish/config.fish`, `~/.tmux.conf`, `~/.inputrc`, `~/.config/starship.toml` — copied as-is
4. Ghostty terminfo: ships `xterm-ghostty.terminfo` and compiles it into
`~/.terminfo` with `tic`, so SSH sessions from Ghostty don't break
ncurses apps. Warns and skips if `tic` isn't installed.
5. `~/.config/ghostty/config` — auto light/dark following GNOME (inert on headless hosts)
| Target | Source |
|---|---|
| `~/.bashrc`, `~/.zshrc`, `~/.inputrc`, `~/.tmux.conf` | `dot_bashrc`, `dot_zshrc`, `dot_inputrc`, `dot_tmux.conf` |
| `~/.zprofile` | `dot_zprofile.tmpl` (flatpak path on desktops) |
| `~/.config/shell/aliases.sh` | `dot_config/shell/aliases.sh.tmpl` |
| `~/.config/fish/conf.d/aliases.fish` | `dot_config/fish/conf.d/aliases.fish.tmpl` |
| `~/.config/fish/config.fish`, `~/.config/starship.toml` | `dot_config/fish/config.fish`, `dot_config/starship.toml` |
| `~/.config/ghostty/config` | `dot_config/ghostty/config` (inert on headless hosts) |
| `~/.config/shell/ghostty.terminfo` | `dot_config/shell/ghostty.terminfo`, compiled into `~/.terminfo` by `.chezmoiscripts/run_after_10-ghostty-terminfo.sh` (skips if `tic` is missing) so SSH from Ghostty keeps ncurses apps working |

## Template data

`home/.chezmoi.toml.tmpl` (regenerated by `apply --init`) provides `machine` and `is_desktop` (from `DOTFILES_MACHINE` / `DOTFILES_IS_DESKTOP`, exported by the unit; `is_desktop` is true when the host is in the `desktop` group of `inventory.yml`). `home/.chezmoidata.yaml` provides `user_name`, `user_email` and `alias_groups`, the single source for the bash/zsh and fish aliases. Add a plain alias there, not in the templates.

## Adding a file

Put it under `home/` using chezmoi names: `dot_` for a leading dot, `.tmpl` suffix to template it, `private_`/`executable_` for modes. chezmoi never deletes files it does not manage.

## Fleet aliases

Expand All @@ -28,5 +39,5 @@ In fish these are abbreviations (`abbr`), not aliases.

## Notes

- Shell secrets (`~/.config/shell/secrets.sh`, `~/.config/fish/conf.d/secrets.fish`) are written by [`shell_ai`](shell_ai.md), not here
- Source files: `roles/shell_dotfiles/files/` and `roles/shell_dotfiles/templates/`
- Shell secrets (`~/.config/shell/secrets.sh`, `~/.config/fish/conf.d/secrets.fish`) are written by the [`shell-ai` unit](shell_ai.md), not here.
- One failing file does not stop the rest: the unit runs `chezmoi apply --init --keep-going --force --no-tty`. This overwrites managed files even when locally edited; back up and review existing dotfiles before adoption. See [Units](../units.md#chezmoi).
Loading