Нема описа

Ralf Beckesch 2e47250935 simplify bootstrap: public repo init deploys wrapper binaries, companion instances init --apply directly пре 5 дана
bin a02cba09f8 rename bin: executable_chezmoi-create-custom -> executable_chezmoi_create-custom (hyphen to underscore); update README references пре 5 дана
dot_bashrc.d 2a36e3d06c Merge branch 'master' of git.beckesch.it:beckesch/dotfiles пре 3 недеља
dot_config 9408f19bdb Sa 17. Okt 09:37:25 CDT 2026 пре 1 месец
README.md 2e47250935 simplify bootstrap: public repo init deploys wrapper binaries, companion instances init --apply directly пре 5 дана
dot_bashrc e2d1c24184 Di 22. Sep 15:49:13 CDT 2026 пре 2 месеци
dot_screenrc 81df0233bb now really adding screenrc and vimrc пре 2 месеци
dot_vimrc 81df0233bb now really adding screenrc and vimrc пре 2 месеци
setup.sh a02cba09f8 rename bin: executable_chezmoi-create-custom -> executable_chezmoi_create-custom (hyphen to underscore); update README references пре 5 дана

README.md

Dotfiles (chezmoi)

Personal dotfiles managed with chezmoi.

The repository lives at github.com/RalfBeckesch/dotfiles.git and is kept locally under ~/.local/share/chezmoi.

Protocol URL
SSH git@github.com:RalfBeckesch/dotfiles.git
HTTPS https://github.com/RalfBeckesch/dotfiles.git

Quick start (new machine)

Public dotfiles (one-command init)

# SSH
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply git@github.com:RalfBeckesch/dotfiles.git

# HTTPS (no SSH key required)
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply https://github.com/RalfBeckesch/dotfiles.git

This deploys shell config, aliases, tools and the wrapper scripts for companion repositories (chezmoi-private and chezmoi-secrets) into ~/.local/bin/. After this completes, the companion instances are ready to be initialized — see Multi-repository architecture.

Companion instances (after public repo is deployed)

Once the public dotfiles are applied, the wrapper binaries are in place:

chezmoi-private init --apply git@git.beckesch.it:rb/chezmoi-private.git
chezmoi-secrets init --apply git@git.beckesch.it:rb/chezmoi-secrets.git

For the secrets instance you may need to set up an age key first — see chezmoi-secrets bootstrap.

Autosetup inside devpods

Use setup.sh from this repository — it installs chezmoi and applies the public dotfiles without asking for a repo URL (devpods only).

Use your distros package manager

# Alpine
apk add chezmoi

# Arch 
pacman -S chezmoi

# Debian
apt-get install chezmoi

# Fedora
dnf install chezmoi

# NixOS
nix-env -i chezmoi

# openSUSE Tumbleweed
zypper install chezmoi

# RHEL (EPEL)
dnf install epel-release && dnf install chezmoi

# Termux
pkg install chezmoi

# Void
xbps-install -S chezmoi

Cross-platform package managers

# am
am -i chezmoi

# asdf
asdf plugin add chezmoi && asdf install chezmoi 2.72.2

# mise
mise use --global chezmoi@2.72.2

# Homebrew
brew install chezmoi

# Nix
nix-env -i chezmoi

# Snap
snap install chezmoi --classic

Structure

Path Description
dot_bashrc Entry point for ~/.bashrc; loads all snippets from ~/.bashrc.d (interactive shells only)
dot_bashrc.d/ Modular bash config snippets, loaded in alphabetical/numeric order
dot_bashrc.d/applications/ Application-specific aliases and additions, loaded by 150-applications.sh (cd, chezmoi, containerlab, date, devpod, grep, kubernetes, ls/lsd, mkdir, ssh, starship, sudo, vi/nvim)
dot_config/ Config files under ~/.config/ (e.g. symlink to starship.toml)
empty_dot_bash_aliases Empty ~/.bash_aliases file (placeholder)
bin/ Wrapper scripts for companion repositories (see below)
setup.sh Bootstrap script: installs chezmoi and applies the repository

bashrc snippet load order

The numbered files in dot_bashrc.d/ are sourced in this order:

  1. 000-bash-setup-generic.sh – basic shell setup
  2. 010-bash-account-specific.sh – account-/machine-specific settings
  3. 100-generic-aliases.sh – general aliases
  4. 150-applications.sh – loads all snippets in applications/
  5. 200-networking.sh – networking aliases and helpers
  6. 300-shell-safety-nets.sh – safety nets (e.g. safer aliases)

Files with a suffix not equal to .sh (e.g. mybashrc.sh-off) are intentionally not loaded.

Multi-repository architecture

This public dotfiles repo is the first of three chezmoi instances that work together but manage disjoint target files:

Instance Source directory Git repository Content Protection
chezmoi ~/.local/share/chezmoi git@github.com:RalfBeckesch/dotfiles.git Public shell config, aliases, portable tools None (public)
chezmoi-private ~/.local/share/chezmoi-private git.beckesch.it:rb/chezmoi-private.git SSH config, ~/.hermes/config.yaml, personal settings Repository access control
chezmoi-secrets ~/.local/share/chezmoi-secrets git.beckesch.it:rb/chezmoi-secrets.git API tokens, .env files, credentials Repository access + age encryption

All three instances use the same chezmoi binary but different source directories, config files, and (for secrets) persistent state. They deploy into the same $HOME without conflict because no target file is managed by more than one instance.

Ownership matrix

Target file Managed by
~/.bashrc, public shell snippets Public repo (chezmoi)
~/.ssh/config Private repo (chezmoi-private)
~/.ssh/authorized_keys Secrets repo (chezmoi-secrets, age-encrypted)
~/.hermes/config.yaml Private repo (chezmoi-private)
Private SSH key files Secrets repo (chezmoi-secrets, age-encrypted)
~/.hermes/.env Secrets repo (chezmoi-secrets)

Companion repositories

Two wrapper scripts in bin/ provide dedicated command names for the companion repositories. Each wrapper invokes chezmoi with the correct --config and --source flags so every command targets the right instance.

chezmoi-private

Purpose: Version-controlled private configuration that does not belong in the public dotfiles repo — SSH config, Hermes configuration, personal scripts.

Wrapper (bin/executable_chezmoi-private.sh):

#!/bin/sh
exec chezmoi \
  --config "$HOME/.config/chezmoi-private/chezmoi.toml" \
  --source "$HOME/.local/share/chezmoi-private" \
  "$@"

Bootstrap on a new machine:

Prerequisites: the public dotfiles must be applied first (the wrapper binary chezmoi-private lands at ~/.local/bin/chezmoi-private via the public repo).

# Initialize and apply from the remote repository
chezmoi-private init --apply git@git.beckesch.it:rb/chezmoi-private.git

# Review before applying — personal config may contain host-specific values
chezmoi-private diff

Daily workflow:

# Add a file to the private repo
chezmoi-private add ~/.ssh/config

# Edit a managed file (chezmoi handles the source → target mapping)
chezmoi-private edit ~/.ssh/config
chezmoi-private apply

# Review pending changes
chezmoi-private status
chezmoi-private diff

# Fetch and apply remote changes
chezmoi-private update

# Git operations from the source directory
git -C ~/.local/share/chezmoi-private status
git -C ~/.local/share/chezmoi-private add --all
git -C ~/.local/share/chezmoi-private commit -m "Update private config"
git -C ~/.local/share/chezmoi-private push

Host-specific template values:

Local config ~/.config/chezmoi-private/chezmoi.toml:

[data]
    hostRole = "workstation"
    sshIdentityFile = "~/.ssh/id_ed25519_personal"

Mark a managed file as a template and inject these values:

chezmoi-private chattr +template ~/.ssh/config
chezmoi-private edit ~/.ssh/config

Inside the template use {{ .sshIdentityFile }} etc. The local config stays on each host — it is not distributed through the repository.

Rules:

  • Always diff before apply
  • A private repository is an access barrier, not encryption — do not commit secrets (API keys, passwords, tokens) here
  • private_ in chezmoi filenames = restrictive file permissions, not encryption

chezmoi-secrets

Purpose: Version-controlled encrypted secrets — API tokens, .env files, and other credentials. File contents are encrypted with age at rest; the repository never sees plaintext.

Wrapper (bin/executable_chezmoi-secrets.sh):

#!/bin/sh
exec chezmoi \
  --config "$HOME/.config/chezmoi-secrets/chezmoi.toml" \
  --source "$HOME/.local/share/chezmoi-secrets" \
  --persistent-state "$HOME/.config/chezmoi-secrets/chezmoistate.boltdb" \
  "$@"

Note the --persistent-state flag — the secrets instance has its own BoltDB state file, keeping it fully isolated from the public and private instances.

Security model and limitations

  • In the source directory and Git repository, file contents are encrypted.
  • When applied, chezmoi decrypts to the target path. Applications read plaintext.
  • File names and directory structure are not hidden — only contents are encrypted.
  • The private age key lives outside the repository (~/.config/chezmoi-secrets/age-key.txt).
  • Anyone who obtains both the age key and the repository can decrypt everything.
  • A compromised host can read secrets deployed to it; encryption in the repo does not change that.
  • A private repository is an additional access barrier, not a substitute for encryption.
  • Plaintext secrets once committed stay in Git history forever — rotate them.

Bootstrap on a new machine

Prerequisites: the public dotfiles must be applied first (the wrapper binary chezmoi-secrets lands at ~/.local/bin/chezmoi-secrets via the public repo).

Step 1 — Generate an age keypair (first host only):

(
  umask 077
  chezmoi-secrets age-keygen --output="$HOME/.config/chezmoi-secrets/age-key.txt"
)
chmod 600 "$HOME/.config/chezmoi-secrets/age-key.txt"

The command prints the public key (age1...). Copy it — you will need it for the config. Back up age-key.txt separately (password manager, encrypted offline backup). Without it, encrypted files in the repository are unrecoverable.

Step 2 — Create the local config:

touch ~/.config/chezmoi-secrets/chezmoi.toml
chmod 600 ~/.config/chezmoi-secrets/chezmoi.toml

Step 3 — Configure encryption:

# ~/.config/chezmoi-secrets/chezmoi.toml
encryption = "age"
useBuiltinAge = true

[add]
    encrypt = true

[age]
    identity = "~/.config/chezmoi-secrets/age-key.txt"
    recipient = "age1_YOUR_PUBLIC_KEY"

add.encrypt = true is a helpful default but not a policy — manually written files in the source directory are not automatically encrypted. Always verify before committing.

Step 4 — Initialize the repository and apply:

chezmoi-secrets init git@git.beckesch.it:rb/chezmoi-secrets.git
chezmoi-secrets diff    # verify before applying
chezmoi-secrets apply

Adding a secret

# Add an existing .env file
chezmoi-secrets add --encrypt ~/.hermes/.env

# Optionally set restrictive permissions explicitly
chezmoi-secrets chattr +private ~/.hermes/.env

Verify the source file is actually encrypted:

chezmoi-secrets status
git -C ~/.local/share/chezmoi-secrets diff --cached
# Should show encrypted content, not plaintext

Daily workflow

# Edit a secret safely — chezmoi decrypts to a private temp dir, opens your
# editor, then re-encrypts when you close it
chezmoi-secrets edit ~/.hermes/.env
chezmoi-secrets apply ~/.hermes/.env

# Status and diff (WARNING: diff decrypts for display)
chezmoi-secrets status
chezmoi-secrets diff ~/.hermes/.env

# Git status and push
git -C ~/.local/share/chezmoi-secrets status
git -C ~/.local/share/chezmoi-secrets add --all
git -C ~/.local/share/chezmoi-secrets commit -m "Update secrets"
git -C ~/.local/share/chezmoi-secrets push

# Update from remote (controlled — no auto-apply)
git -C ~/.local/share/chezmoi-secrets pull --ff-only
chezmoi-secrets apply ~/.hermes/.env

Multi-host setup (shared or per-host keys)

Shared key — simplest model: copy age-key.txt to each host via a secure channel (password manager, encrypted USB). Use the same recipient in every config. Configuration on the next host is identical except for steps 2-4.

Per-host keys — each host gets its own keypair. Add all public keys as recipients:

[age]
    identity = "~/.config/chezmoi-secrets/age-key.txt"
    recipients = [
        "age1PUBLIC_KEY_LAPTOP",
        "age1PUBLIC_KEY_DESKTOP",
    ]

Important limits with per-host keys:

  • All hosts must use the complete recipient list when re-encrypting files.
  • Changing the recipient list does not retroactively re-encrypt existing files. For a new recipient, re-add affected files with add --encrypt on an already authorized host.
  • Removing a recipient does not revoke access to older Git history entries that were encrypted for their key. If access must be revoked, rotate the secrets.
  • Multiple recipients means every listed key can decrypt every file — there is no per-host file separation within one repo. For separate trust domains, use separate repos or a file-level encryption strategy.

What this setup does NOT provide

  • No central password manager integration
  • No time-limited or dynamically generated secrets
  • No automatic API key rotation
  • No encryption of deployed target files at rest
  • No automatic Git history cleanup
  • No automatic host-based access separation within a shared-key repo
  • No passphrase-protected age identity — the local key file relies on filesystem permissions and a secure backup strategy

Checklist for a new secrets host

  • Secrets repository is private
  • age key created and backed up separately
  • Private age key is NOT in the repository
  • [add] encrypt = true is set
  • Added file contents are actually encrypted (verified via git diff --cached)
  • No target file is also managed by the public or private chezmoi instance
  • No ancestor exact_ directory removes files managed by another instance
  • Target files have restrictive permissions
  • Only secrets this host actually needs are deployed
  • Recovery from a backed-up age key has been tested

chezmoi_create_custom

Purpose: Helper script to bootstrap a new companion chezmoi repository — creates the wrapper script with correct --config and --source paths for a custom instance name.

Script (bin/executable_chezmoi_create-custom.sh):

#!/bin/sh
# Usage: ./bin/executable_chezmoi_create-custom.sh <name>
#
# Creates ~/bin/chezmoi-<name>.sh with:
#   --config  "$HOME/.config/chezmoi-<name>/chezmoi.toml"
#   --source  "$HOME/.local/share/chezmoi-<name>"
#
# Exits with an error if any of the three files/directories already exist.

Usage example — creating a chezmoi-work instance:

# Create the wrapper
./bin/executable_chezmoi_create-custom.sh work

# Set up the companion repo manually (wrapper exists, but config + source
# directories are still empty)
mkdir -p ~/.config/chezmoi-work ~/.local/share/chezmoi-work
touch ~/.config/chezmoi-work/chezmoi.toml
chmod 600 ~/.config/chezmoi-work/chezmoi.toml

# Initialize from a remote
chezmoi-work init git@example.com:user/chezmoi-work.git
chezmoi-work diff
chezmoi-work apply

The script is idempotent — it refuses to overwrite an existing wrapper, config, or source directory. Delete those manually if you need to recreate an instance.


Common workflows

# Bring a file from your home directory into the public repo
chezmoi add ~/.bashrc.d/my-snippet.sh

# Edit a managed file
chezmoi edit ~/.bashrc.d/my-snippet.sh

# Update and apply the public dotfiles
chezmoi update

# Show the diff between the repo and the actual home directory
chezmoi diff

# Sync on another machine
chezmoi cd   # opens the source directory; then git pull/push as usual

Debugging the bashrc

The file ~/.BASHRC_DEBUG controls the debug output of ~/.bashrc: If it exists, its content is set as the debug level and messages are printed while the snippets are loaded (see debug() in dot_bashrc).