Something went wrong. Try again.
My dotfiles
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220# Dotfiles: GNU Stow packages plus the fish secret and Claude skill links.# Run inside the devenv shell (or `devenv shell -- just ...`).
export SECRETS_DIR := env("SECRETS_DIR", home_directory() / "projects/data")
packages := "nvim atuin opencode skills fish niri jj claude misc ssh pigeons"target := home_directory()stow := "stow --dir=stow --target=" + quote(target) + " --verbose=1"
default: @just --list
# Back up the current (pre-stow) config files to ~/backups.backup: #!/usr/bin/env bash set -euo pipefail stamp=$(date +%Y%m%d-%H%M%S) dest="$HOME/backups/dotfiles-pre-stow-$stamp.tar.gz" mkdir -p "$HOME/backups" paths=() for p in \ .config/nvim .atuin/config.toml \ .config/opencode/opencode.jsonc .config/opencode/cli.json .config/opencode/service.json \ .config/fish .config/niri .config/jj/config.toml \ .claude/settings.json .config/mimeapps.list .config/git/ignore \ .ssh/config .ssh/config.d .agents; do if [[ -e "$HOME/$p" ]]; then paths+=("$p") fi done if (( ${#paths[@]} == 0 )); then echo "backup: nothing to back up" >&2 exit 0 fi tar -czf "$dest" -C "$HOME" --exclude=node_modules "${paths[@]}" echo "backup: $dest"
# Reload services that read their config at startup. Install does not do this.reload: #!/usr/bin/env bash set -euo pipefail if niri msg version >/dev/null 2>&1; then niri msg action load-config-file echo "reload: niri config reloaded" >&2 fi if atuin daemon status >/dev/null 2>&1; then atuin daemon restart echo "reload: atuin daemon restarted" >&2 fi echo "reload: restart OpenCode, Claude, nvim, and fish shells to pick up their configs." >&2
# Keep ~/.config/niri a real directory so stow cannot fold it into the repo.niri-guard: #!/usr/bin/env bash set -euo pipefail if [[ -L "$HOME/.config/niri" ]]; then echo "niri-guard: ~/.config/niri is a symlink; run the one-time migration in MIGRATING.md first." >&2 exit 1 fi mkdir -p "$HOME/.config/niri/cfg"
# Replace a stock niri keybinds file with the tracked one, saving the old file.niri-keybinds: #!/usr/bin/env bash set -euo pipefail target="$HOME/.config/niri/cfg/keybinds.kdl" source="{{justfile_directory()}}/stow/niri/.config/niri/cfg/keybinds.kdl" mkdir -p "$(dirname "$target")" if [[ -L "$target" ]]; then if [[ "$(readlink -f "$target")" != "$(readlink -f "$source")" ]]; then backup="$target.pre-dotfiles.$(date +%Y%m%d-%H%M%S)" mv "$target" "$backup" echo "niri-keybinds: saved existing symlink to $backup" >&2 fi elif [[ -e "$target" ]]; then backup="$target.pre-dotfiles.$(date +%Y%m%d-%H%M%S)" mv "$target" "$backup" echo "niri-keybinds: saved existing keybinds to $backup" >&2 fi
# Keep the systemd and pigeons directories real so stow cannot fold them into the repo.pigeons-guard: #!/usr/bin/env bash set -euo pipefail # A folded ~/.config/systemd/user would make `systemctl --user enable` write into the repo. mkdir -p "$HOME/.config/systemd/user" "$HOME/.config/pigeons" install -d -m 700 "$HOME/.ssh/pigeons-ids"
# Install the hardened sshd drop-in with sudo; rolls back if `sshd -t` rejects it.sshd-install: #!/usr/bin/env bash set -euo pipefail # Does not enable or start sshd; see README.md, "Remote SSH (pigeons)". src="{{justfile_directory()}}/system/sshd/10-hardening.conf" dest=/etc/ssh/sshd_config.d/10-hardening.conf # A machine that never ran sshd has no host keys, and `sshd -t` needs them. # -A only creates the missing ones. sudo ssh-keygen -A backup="" if sudo test -e "$dest"; then backup=$(mktemp) sudo cp "$dest" "$backup" fi sudo install -m 644 -o root -g root "$src" "$dest" if ! sudo sshd -t; then if [[ -n "$backup" ]]; then sudo install -m 644 -o root -g root "$backup" "$dest" echo "sshd-install: sshd -t failed; restored the previous $dest" >&2 else sudo rm -f "$dest" echo "sshd-install: sshd -t failed; removed $dest" >&2 fi rm -f "$backup" exit 1 fi rm -f "$backup" echo "sshd-install: installed $dest" >&2 if systemctl is-active --quiet sshd; then echo "sshd-install: sshd is running; apply with: sudo systemctl reload sshd" >&2 fi
# Create symlinks, decrypt fish secrets if needed, and link Claude skills.install: niri-guard niri-keybinds pigeons-guard secrets {{stow}} {{packages}} @just link-claude-skills @just herdr
# Refresh symlinks after adding or moving files.restow: niri-guard niri-keybinds pigeons-guard secrets {{stow}} --restow {{packages}} @just link-claude-skills @just herdr
# Dry-run stow and report conflicts.check: {{stow}} --simulate {{packages}}
# Remove the managed symlinks.delete: {{stow}} --delete {{packages}}
# Expose ~/.agents/skills to Claude via symlinks.link-claude-skills: bash ./scripts/link-claude-skills
# Install herdr/ into the Herdr app: each mod in herdr/mods/ (then# `herdr-app check` on it), the layouts in herdr/layouts/, keys.json,# settings.json and the themes in herdr/themes/.# Copied, not stowed: Herdr doesn't pick up or hot-reload a symlinked mod# folder. A layout, keys.json or settings.json changed in the app since the last install is# left alone with a diff (HERDR_FORCE=1 overwrites it). Skipped where the# Herdr app isn't installed.herdr: #!/usr/bin/env bash set -euo pipefail if ! command -v herdr-app >/dev/null; then echo "herdr: herdr-app not installed, skipping" exit 0 fi app="${HERDR_APP_HOME:-$HOME/.config/herdr-app}" state="${XDG_STATE_HOME:-$HOME/.local/state}/dotfiles/herdr" mkdir -p "$app/mods" "$app/layouts" "$state/layouts" for mod in herdr/mods/*/; do name=$(basename "$mod") rsync -a --delete --exclude gpui-kit.d.ts --exclude jsconfig.json "$mod" "$app/mods/$name/" herdr-app check "$app/mods/$name" done # Copies $1 to $2 unless $2 was changed since this recipe last wrote it ($3). place() { local src=$1 dest=$2 last=$3 if [[ -e "$dest" ]] && ! cmp -s "$src" "$dest" && ! cmp -s "$dest" "$last" && [[ "${HERDR_FORCE:-}" != 1 ]]; then echo "herdr: $dest was changed in the app; not overwriting (HERDR_FORCE=1 to replace it):" >&2 diff -u "$dest" "$src" >&2 || true return fi cp "$src" "$dest" cp "$src" "$last" } for layout in herdr/layouts/*.json; do name=$(basename "$layout") place "$layout" "$app/layouts/$name" "$state/layouts/$name" done place herdr/keys.json "$app/keys.json" "$state/keys.json" place herdr/settings.json "$app/settings.json" "$state/settings.json" # Themes are ours alone: herdr/themes/*.json as is. mkdir -p "$app/themes" cp herdr/themes/*.json "$app/themes/" for f in layouts.error keys.error; do if [[ -e "$app/$f" ]]; then echo "herdr: $app/$f:" >&2; cat "$app/$f" >&2; exit 1; fi done
# Decrypt the fish secrets if the plaintext file is missing or older.secrets: #!/usr/bin/env bash set -euo pipefail target="$HOME/.config/fish/secrets.fish" vault="${SECRETS_DIR:-$HOME/projects/data}/dotfiles/fish/secrets.fish.age" if [[ -s "$target" && -f "$vault" && "$target" -nt "$vault" ]]; then exit 0 fi umask 077 echo "secrets: enter your YubiKey PIN, then touch the YubiKey when it blinks." >&2 echo "secrets: there is no separate touch prompt; the key must be touched after the PIN." >&2 tmp=$(mktemp) trap 'rm -f "$tmp"' EXIT secrets decrypt dotfiles/fish/secrets.fish > "$tmp" install -m 600 "$tmp" "$target"
# Force a re-decrypt, e.g. after rotating the vault entry.secrets-refresh: #!/usr/bin/env bash set -euo pipefail umask 077 echo "secrets: enter your YubiKey PIN, then touch the YubiKey when it blinks." >&2 echo "secrets: there is no separate touch prompt; the key must be touched after the PIN." >&2 tmp=$(mktemp) trap 'rm -f "$tmp"' EXIT secrets decrypt dotfiles/fish/secrets.fish > "$tmp" install -m 600 "$tmp" "$HOME/.config/fish/secrets.fish"