Files
dotfiles/README.md

271 lines
6.9 KiB
Markdown

# Dotfiles - Multi-Machine Configuration Management
Ein **einfaches** und sicheres System zur Verwaltung von Konfigurationsdateien (Dotfiles) über mehrere Rechner hinweg. Nach dem **KISS-Prinzip**: Keep It Simple, Stupid.
## ✨ Features
- 🖥️ **Multi-Machine Support**: Separate Konfigurationen für Desktop, Laptop, Server
- 🔗 **Symlink-basiert**: Keine Kopien, direkte Verknüpfungen zu deinen Configs
- 🔐 **Sichere Verschlüsselung**: Sensible Daten mit transcrypt verschlüsselt
- ⚙️ **Konfigurationsgesteuert**: Alles wird über `config.yaml` definiert
- 🚀 **Ein Skript für alles**: Nur noch ein einziges `dotfiles` Kommando
- 🎯 **Automatische Erkennung**: Maschinenerkennung ohne manuelle Konfiguration
## 📂 Struktur
```
configs/
├── machines/ # Maschinenspezifische Konfigurationen
│ ├── desktop/ # Desktop-Computer Configs
│ ├── laptop/ # Laptop/Notebook Configs
│ └── server/ # Server-System Configs
├── shared/ # Geteilte Konfigurationen
│ ├── shell/ # Shell-Configs (bash, zsh, etc.)
│ ├── vim/ # Vim-Konfiguration
│ ├── git/ # Git-Konfiguration
│ └── ssh/ # SSH-Konfiguration (öffentlich)
├── sensitive/ # Verschlüsselte sensible Daten
├── dotfiles # ⭐ DAS zentrale Management-Skript
├── config.yaml # ⚙️ Zentrale Konfiguration (definiert alles!)
└── README.md # Diese Dokumentation
```
## 🚀 Schnellstart
### 1. Repository klonen
```bash
git clone <your-dotfiles-repo-url> ~/.dotfiles
cd ~/.dotfiles
```
### 2. Dotfiles installieren
```bash
./dotfiles install
```
### 3. Aktuelle Configs sichern
```bash
./dotfiles push
```
### 4. Verschlüsselung einrichten (optional)
```bash
./dotfiles setup-transcrypt
```
## 📋 Alle Befehle
### Installation und Management
```bash
./dotfiles install # Installiere alle Dotfiles (Symlinks)
./dotfiles push # Sammle und committe aktuelle Configs
./dotfiles push --push # Sammle, committe und push zu Remote
./dotfiles list # Zeige installierte Konfigurationen
```
### Verschlüsselung
```bash
./dotfiles setup-transcrypt # Interaktive Transcrypt-Einrichtung
./dotfiles setup-transcrypt --auto-password # Mit automatischem Passwort
./dotfiles setup-transcrypt --force # Erneut konfigurieren
```
### Hilfe
```bash
./dotfiles help # Zeige alle verfügbaren Befehle
```
## ⚙️ Konfiguration über config.yaml
**Das Herzstück**: Alle Symlinks, Push-Quellen und Einstellungen werden in `config.yaml` definiert!
### Neue Konfiguration hinzufügen
Bearbeite `config.yaml` und füge hinzu:
```yaml
# In der symlinks -> shared Sektion:
- src: "shared/tmux/tmux.conf"
dest: "~/.tmux.conf"
description: "Tmux-Konfiguration"
# In der push_sources -> shared Sektion:
- src: "~/.tmux.conf"
dest: "shared/tmux/tmux.conf"
description: "Tmux-Konfiguration"
```
### Maschinenspezifische Configs
```yaml
# Für Desktop-spezifische Konfigurationen:
- src: "machines/{machine}/i3_config"
dest: "~/.config/i3/config"
description: "i3-Konfiguration"
```
### Vordefinierte Konfigurationen
`config.yaml` enthält bereits Definitionen für:
- tmux
- neovim
- vscode
- i3
## 🔐 Sichere Daten
### Automatische Verschlüsselung
Alle Dateien in folgenden Orten werden automatisch verschlüsselt:
- `sensitive/` - Allgemeine sensible Daten
- `machines/*/secrets/` - Maschinenspezifische Geheimnisse
- Dateien mit Namen wie `*secret*`, `*.key`, `*.pem`
- SSH private keys (`id_rsa`, `id_ed25519`, etc.)
### Sensible Dateien hinzufügen
```bash
# Einfach in die entsprechenden Verzeichnisse kopieren
cp ~/.ssh/id_rsa sensitive/ssh/id_rsa # Wird automatisch verschlüsselt
cp ~/.env sensitive/env/myproject.env # Wird automatisch verschlüsselt
echo "API_KEY=secret123" > sensitive/api_keys.txt # Wird automatisch verschlüsselt
```
## 🔧 Konfigurationen hinzufügen/entfernen
### Neue Konfiguration hinzufügen
1. **Datei manuell kopieren**:
```bash
mkdir -p shared/tmux
cp ~/.tmux.conf shared/tmux/tmux.conf
```
2. **config.yaml erweitern**:
- Symlink-Definition zu `symlinks -> shared` hinzufügen
- Push-Definition zu `push_sources -> shared` hinzufügen
3. **Testen und sichern**:
```bash
./dotfiles install # Test der neuen Symlinks
./dotfiles push # Änderungen sichern
```
### Konfiguration entfernen
1. **Aus config.yaml entfernen** (entsprechende Zeilen löschen)
2. **Symlink entfernen**: `rm ~/.tmux.conf`
3. **Aus Repository entfernen**: `rm -rf shared/tmux/`
4. **Backup wiederherstellen** (falls vorhanden): `mv ~/.tmux.conf.backup.* ~/.tmux.conf`
## 📚 Beispiel-Workflows
### Neuer Computer einrichten
```bash
# 1. Repository klonen
git clone git@github.com:username/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
# 2. Transcrypt entschlüsseln (falls vorhanden)
transcrypt -y
# 3. Dotfiles installieren
./dotfiles install
# 4. Shell neu starten
exec $SHELL
```
### Konfiguration ändern und teilen
```bash
# 1. Lokale Änderungen machen
vim ~/.vimrc
# 2. Ins Repository sichern und pushen
./dotfiles push --push
# 3. Auf anderen Maschinen updaten
git pull
./dotfiles install # Falls neue Dateien hinzugekommen sind
```
### Neue Anwendung hinzufügen (Beispiel: Tmux)
```bash
# 1. Konfiguration ins Repository kopieren
mkdir -p shared/tmux
cp ~/.tmux.conf shared/tmux/tmux.conf
# 2. config.yaml bearbeiten (Definitionen hinzufügen)
vim config.yaml
# 3. Testen
./dotfiles install
# 4. Sichern
./dotfiles push
```
## 🔍 Troubleshooting
### Problem: "YAML-Parser-Fehler"
```bash
# Prüfe YAML-Syntax
python3 -c "import yaml; yaml.safe_load(open('config.yaml'))"
```
### Problem: "Symlink funktioniert nicht"
```bash
# Prüfe Symlink-Ziel
readlink ~/.vimrc
# Liste installierte Symlinks
./dotfiles list
```
### Problem: "Transcrypt-Fehler"
```bash
# Status prüfen
transcrypt --display
# Neu konfigurieren
./dotfiles setup-transcrypt --force
```
## ⚠️ Wichtige Hinweise
1. **config.yaml ist der Schlüssel**: Alle Änderungen werden dort definiert
2. **Backup**: Existierende Dateien werden automatisch gesichert
3. **KISS-Prinzip**: Ein Skript, eine Konfigurationsdatei - einfach!
4. **Transcrypt-Passwort**: Sicher aufbewahren!
## 🎯 Migration von alten Dotfiles-Systemen
Falls du von einem anderen Dotfiles-System migrierst:
```bash
# 1. Aktuelle Symlinks entfernen
find ~ -maxdepth 2 -type l -delete
# 2. Konfigurationen ins neue System kopieren
cp ~/.vimrc shared/vim/vimrc
cp ~/.gitconfig shared/git/gitconfig
# ... weitere Dateien
# 3. config.yaml entsprechend anpassen
# 4. Neu installieren
./dotfiles install
```
---
**Das war's!** Ein Skript, eine Konfigurationsdatei - dotfiles management kann so einfach sein! 🚀
Nach dem **KISS-Prinzip**: Keep It Simple, Stupid. ✨