This dotfiles setup supports two machine profiles: work and personal. The profile determines which packages are installed, which configurations are applied, and which environment variables are set.
The profile is auto-detected from your machine's hostname during chezmoi init:
// In .chezmoi.toml.tmpl
{{- $machineType := "personal" -}}
{{- if or (contains "work" .chezmoi.hostname) (contains "corp" .chezmoi.hostname) (contains "talview" .chezmoi.hostname) -}}
{{- $machineType = "work" -}}
{{- end -}}Hostnames that trigger "work" profile:
- Contains
work(e.g.,macbook-work) - Contains
corp(e.g.,corp-laptop) - Contains
talview(e.g.,talview-dev)
During first run, you're prompted to confirm or change:
Machine type (work/personal) [personal]:
To change later, edit ~/.config/chezmoi/chezmoi.toml:
[data.machine]
type = "work" # Change to "personal" or "work"Then re-apply:
chezmoi applyWhen .machine.type == "work":
| Category | Behavior |
|---|---|
| npm packages | Installs @openai/codex CLI |
| Environment | Sets CODEX_BASE_URL for LiteLLM proxy |
| Paths | Adds work-specific tool paths |
| Aliases | Work-related shortcuts |
When .machine.type == "personal":
| Category | Behavior |
|---|---|
| npm packages | Skips work-specific tools |
| Environment | No work proxy configuration |
| Config files | Excludes .codex.work/ directory |
In dot_zshrc.tmpl:
{{ if .machine.isWork }}
# Work-specific settings
export JIRA_PROJECT="TEAM"
alias standup='open "https://meet.google.com/xxx-xxxx-xxx"'
{{ end }}In dot_config/zsh/conf.d/00-path.zsh.tmpl:
{{ if .machine.isWork }}
# Work tools path
typeset -U path
path=(
"$HOME/.work-tools/bin"
$path
)
{{ end }}In run_onchange_before_install-packages-darwin.sh.tmpl:
# npm globals - work only
{{ if .machine.isWork }}
npm install -g @openai/codex
{{ end }}In dot_codex.work/private_config.toml.tmpl (only applied on work machines):
[api]
base_url = "{{ .codex.baseUrl }}"The .chezmoiignore file excludes work-specific files on personal machines:
{{ if not .machine.isWork }}
.codex.work/
{{ end }}
This means:
- Work machines:
.codex.work/directory is applied - Personal machines:
.codex.work/directory is completely ignored
| Variable | Type | Description |
|---|---|---|
.machine.type |
string | "work" or "personal" |
.machine.isWork |
bool | true if work machine |
.machine.isPersonal |
bool | true if personal machine |
Profiles work alongside OS detection:
{{ if and .machine.isWork .machine.isDarwin }}
# Work Mac specific
{{ end }}
{{ if and .machine.isPersonal .machine.isLinux }}
# Personal Linux specific
{{ end }}{{ if .machine.isWork }}
# Your work-specific config here
{{ end }}In .chezmoiignore:
{{ if not .machine.isWork }}
path/to/work-only-file
{{ end }}
In .chezmoi.toml.tmpl:
{{- $workTool := "" -}}
{{- if eq $machineType "work" -}}
{{- $workTool = promptStringOnce . "work.tool" "Work tool URL" "https://default.url" -}}
{{- end -}}
[data.work]
tool = {{ $workTool | quote }}# View all template data including profile
chezmoi data | grep -A5 '"machine"'
# Or just the type
chezmoi execute-template '{{ .machine.type }}'Example output:
"machine": {
"type": "work",
"isWork": true,
"isPersonal": false,
...
}To switch a machine's profile:
-
Edit the config:
$EDITOR ~/.config/chezmoi/chezmoi.toml
-
Change the type:
[data.machine] type = "personal" # or "work"
-
Re-apply:
chezmoi apply
-
Reload shell:
exec zsh
- TEMPLATES.md - Template syntax and all variables
- PACKAGES.md - Profile-specific packages
- ARCHITECTURE.md - How profiles fit in the system