7 İşlemeler 24900cedbb ... 9117611470

Yazar SHA1 Mesaj Tarih
  Ralf Beckesch 9117611470 use placeholder repo URLs for optional companion instances in quick start 5 gün önce
  Ralf Beckesch 0222409007 restructure README: quick start with optional companion instances + own ## sections for private/secrets 5 gün önce
  Ralf Beckesch 2e47250935 simplify bootstrap: public repo init deploys wrapper binaries, companion instances init --apply directly 5 gün önce
  Ralf Beckesch 817cd70218 fix ownership matrix table formatting: restore single-pipe prefix (patch had doubled to ||) 5 gün önce
  Ralf Beckesch 588235d324 fix ownership matrix: SSH authorized_keys and private key files belong to secrets repo (age-encrypted), not separate provisioning 5 gün önce
  Ralf Beckesch dbf13e1483 Di 24. Nov 18:14:41 EST 2026 5 gün önce
  Ralf Beckesch a02cba09f8 rename bin: executable_chezmoi-create-custom -> executable_chezmoi_create-custom (hyphen to underscore); update README references 5 gün önce
3 değiştirilmiş dosya ile 390 ekleme ve 30 silme
  1. 357 15
      README.md
  2. 9 7
      bin/executable_chezmoi_create-custom.sh
  3. 24 8
      setup.sh

+ 357 - 15
README.md

@@ -2,28 +2,34 @@
 
 Personal dotfiles managed with [chezmoi](https://www.chezmoi.io/).
 
-The repository lives at `git.beckesch.it:beckesch/dotfiles.git` and is kept locally
+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)
-### Install script from chezmoi.io
+
+One-command init — deploys shell config, aliases, tools **and** the
+wrapper binaries for the companion repositories into `~/.local/bin/`:
 
 ```sh
-sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply git@git.beckesch.it:beckesch/dotfiles.git
+sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply git@github.com/RalfBeckesch/dotfiles.git
 ```
 
-### Install with your distros or cross-platform package manager first...
-...then initialize chezmoi with the repository
+**Optional companion instances** (run after the public repo is applied):
 
+```bash
+chezmoi-private init --apply <your-private-repo-url>   # see ## chezmoi-private
+chezmoi-secrets init --apply <your-secrets-repo-url>   # see ## chezmoi-secrets (age key may be needed)
 ```
-chezmoi init git@git.beckesch.it:beckesch/dotfiles.git
-```
-### Autosetup the files inside your devpods
 
-Alternatively, use the `setup.sh` script in this repository, which installs chezmoi
-and applies the dotfiles if that hasn't happened yet. The `setup.sh` is intended to be used as `devpod` quick setup.
+### Autosetup inside devpods
 
-see `setup.sh`
+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
 ```
@@ -76,8 +82,6 @@ nix-env -i chezmoi
 snap install chezmoi --classic
 ```
 
-
-
 ## Structure
 
 | Path | Description |
@@ -87,6 +91,7 @@ snap install chezmoi --classic
 | `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
@@ -102,13 +107,350 @@ The numbered files in `dot_bashrc.d/` are sourced in this order:
 
 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`):
+
+```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).
+
+```bash
+# 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:**
+
+```bash
+# 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`:
+
+```toml
+[data]
+    hostRole = "workstation"
+    sshIdentityFile = "~/.ssh/id_ed25519_personal"
+```
+
+Mark a managed file as a template and inject these values:
+
+```bash
+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](https://age-encryption.org/)
+at rest; the repository never sees plaintext.
+
+**Wrapper** (`bin/executable_chezmoi-secrets.sh`):
+
+```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):**
+
+```bash
+(
+  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:**
+
+```bash
+touch ~/.config/chezmoi-secrets/chezmoi.toml
+chmod 600 ~/.config/chezmoi-secrets/chezmoi.toml
+```
+
+**Step 3 — Configure encryption:**
+
+```toml
+# ~/.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:**
+
+```bash
+chezmoi-secrets init git@git.beckesch.it:rb/chezmoi-secrets.git
+chezmoi-secrets diff    # verify before applying
+chezmoi-secrets apply
+```
+
+### Adding a secret
+
+```bash
+# 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:
+
+```bash
+chezmoi-secrets status
+git -C ~/.local/share/chezmoi-secrets diff --cached
+# Should show encrypted content, not plaintext
+```
+
+### Daily workflow
+
+```bash
+# 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:
+
+```toml
+[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`):
+
+```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:**
+
+```bash
+# 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
 
 ```sh
-# Bring a file from your home directory into the repo
+# Bring a file from your home directory into the public repo
 chezmoi add ~/.bashrc.d/my-snippet.sh
 
-# Update and apply the dotfiles
+# 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

+ 9 - 7
bin/executable_chezmoi-create-custom.sh → bin/executable_chezmoi_create-custom.sh

@@ -1,4 +1,6 @@
 
+#!/bin/sh
+
 name="$1"
 prefix="chezmoi"
 postfix="sh"
@@ -8,26 +10,26 @@ config="$HOME/.config/chezmoi-$name/chezmoi.toml"
 dir="$HOME/.local/share/chezmoi-$name"
 
 if [ -e "$fn" ]; then
-	echo -e "\n'$fn' already exists!\n"
+	printf '\n'"'$fn' already exists!\n"'\n'
 	exit 1
 fi
 
 if [ -e "$config" ]; then
-	echo -e "\n'$config' already exists!\n"
+	printf '\n'"'$config' already exists!\n"'\n'
 	exit 1
 fi
 
 if [ -e "$dir" ]; then
-	echo -e "\n'$dir' already exists!\n"
+	printf '\n'"'$dir' already exists!\n"'\n'
 	exit 1
 fi
 
-cat <<EOF >> $fn
+cat <<EOF > $fn
 #!/bin/sh
 exec chezmoi \
-  --config "$HOME/.config/chezmoi-private/chezmoi.toml" \
-  --source "$HOME/.local/share/chezmoi-private" \
-  "$@"
+  --config "$HOME/.config/chezmoi-$name/chezmoi.toml" \
+  --source "$HOME/.local/share/chezmoi-$name" \
+  "\$@"
 EOF
 
 chmod 755 $fn

+ 24 - 8
setup.sh

@@ -1,14 +1,30 @@
 #!/bin/bash
+#
+# Bootstrap chezmoi and apply the public dotfiles repository.
+#
+# Usage:
+#   ./setup.sh
+#
+# Installs chezmoi if missing, then initializes and applies the public
+# dotfiles from git.beckesch.it:beckesch/dotfiles.git.
 
-local_bin=$HOME/.local/bin  
+set -euo pipefail
 
-PATH=$PATH:/bin
+readonly local_bin="${HOME}/.local/bin"
+readonly public_repo="git@git.beckesch.it:beckesch/dotfiles.git"
 
-set -euo pipefail
+# --
+# 1. Install chezmoi if missing
+# --
+if ! command -v chezmoi >/dev/null; then
+  mkdir -p "$local_bin"
+  /bin/sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$local_bin" init --apply "$public_repo"
+fi
 
-#  
-# Install "chezmoi" if not installed  
-#  
-if ! command -v chezmoi >/dev/null; then  
-	/bin/sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $local_bin init --apply git@git.beckesch.it:beckesch/dotfiles.git 
+# --
+# 2. Init/apply the public dotfiles repo
+# --
+if ! chezmoi source-path >/dev/null 2>&1; then
+  chezmoi init "$public_repo"
 fi
+chezmoi apply