Skip to content
mgajewskikPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

94 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotfiles

My shell, editor, terminal and Sway desktop setup, managed with chezmoi. One command sets up a desktop, a server or a container without asking anything, and mise installs my tools at the versions pinned in a lockfile. On NixOS, Nix installs them instead and mise stays for projects.

flowchart LR
    Crib["crib up"] -->|setup.sh| Install
    Install["chezmoi init --apply"] --> Detect{"Which machine?"}
    Detect -->|desktop| Desktop["Everything"]
    Detect -->|"server (SSH)"| Server["No terminals, fonts<br/>or desktop session"]
    Detect -->|container| Container["Server set, no crib,<br/>Chrome for Testing on amd64"]
    Desktop & Server & Container --> Apply
    subgraph Apply["Every apply"]
        Dotfiles["Dotfiles<br/>zsh, tmux, git, herdr, yazi"]
        Tools["mise tools<br/>pinned by mise.lock"]
        Externals["nvim config, agent skills,<br/>zsh plugins"]
        Claude["Claude Code<br/>settings, plugins, MCP"]
        Pi["pi<br/>settings, extensions, MCP"]
        Gpg["gpg public key"]
    end
Loading

New machine

sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply mgajewskik
  • Dotfiles already there: drop --apply, read chezmoi diff, then chezmoi apply.
  • YubiKey on this machine: install its packages first, so the first apply imports my public key.
  • Desktop set up over SSH: env -u SSH_CONNECTION chezmoi init, or it counts as a server.
  • What it detected: chezmoi data | grep -E '"(remote|container|nixos)"'.
  • Another git identity on this machine: a [user] block in ~/.gitconfig.local, which git reads last.

Day to day

I want to I run
edit a dotfile chezmoi edit ~/.zshrc, then chezmoi apply
keep a change I made in place chezmoi re-add ~/.zshrc
see what apply would change chezmoi diff
commit and push chezmoi cd, then git as usual
pull and apply on another machine chezmoi update
same, plus nvim, skills, plugins chezmoi update -R -k

c is my alias for chezmoi. The nvim config is its own repo: I commit and push it from ~/.config/nvim.

Tools and plugins

  • mise, outside a container and not on NixOS (containers lack crib, so locking there drops it):
    • add: put it in dot_config/mise/config.toml.tmpl, then chezmoi apply
    • upgrade all: mise lock -g --bump && mise install
    • remove: delete it from the config, then mise lock -g
    • then chezmoi add ~/.config/mise/mise.lock
  • Nix, on NixOS: the same tools from nixos-unstable in nixos/modules/tools.nix (crib in nixos/modules/pkgs/crib.nix), which x1 installs system-wide, chezmoi and mise included; jq comes from stable. A tool added to mise goes there too, then nh os switch. Moving a host over, devenv, and NixOS agent containers: nixos/devenv/README.md.
  • yazi: after ya pkg add or ya pkg upgrade, chezmoi re-add ~/.config/yazi/package.toml.
  • herdr: plugins are listed in .chezmoiscripts/run_onchange_after_plugins_herdr.sh.tmpl; changing its refreshed: date updates them all.
  • tmux: prefix I installs, prefix U updates.
  • Claude Code: plugins go in enabledPlugins in .chezmoitemplates/claude/settings.json, MCP servers in .chezmoiscripts/run_onchange_after_plugins_claude.sh.tmpl.
  • pi: after editing an extension in place, chezmoi re-add ~/.pi/agent; a new one needs chezmoi add ~/.pi/agent/extensions/<file>. Settings and MCP servers go in dot_pi/agent/modify_settings.json and modify_mcp.json, which set their keys and keep the ones pi writes itself. crib copies ~/.pi/agent/auth.json into each container; elsewhere, /login in pi.
  • After changing .chezmoi.toml.tmpl, I run chezmoi init on each machine before the next apply, or the templates fail with map has no entry for key.

YubiKey

sudo pacman -S --needed gnupg pcsclite ccid                         # Arch
sudo apt install gnupg scdaemon pcscd                               # Debian/Ubuntu
sudo dnf install gnupg2 pcsc-lite pcsc-lite-ccid                    # RHEL/Rocky
sudo dnf install gnupg2 gnupg2-scdaemon pcsc-lite pcsc-lite-ccid    # Fedora 43+
sudo systemctl enable --now pcscd.socket
gpg --card-status

Containers

My dotfiles go into any project's container through crib, which clones this repo and runs setup.sh. To start from my default container, in the project root:

mkdir -p .devcontainer && cp ~/.local/share/chezmoi/.devcontainer/default/devcontainer.json .devcontainer/
cp ~/.local/share/chezmoi/.devcontainer/default/.cribrc .
claude-path                           # creates the host folder for Claude's memory mount
echo .cribrc >> .git/info/exclude     # in someone else's repo
crib up && crib shell

For the project's own dependencies, I add an executable .devcontainer/setup.sh. The container runs it from the project root on every start, after my dotfiles (so mise and its tools are there), which means it has to be safe to re-run.

I want to I run
start it and get a shell crib up, then crib shell
apply changed mounts, env, ports, runArgs crib restart
apply a changed image or features crib rebuild
pause it crib stop
remove it (the next up recreates it) crib down
remove it with its images and state crib remove

To test this repo, crib up && crib shell in the checkout runs setup.sh from the working tree, uncommitted changes included. Its desktop is at http://localhost:6080 (password vscode). After changing setup.sh: crib rebuild. The first time on a host, the Claude folder and gpg socket it mounts must exist:

mkdir -p ~/.claude/projects/-workspaces-chezmoi-mount && gpg-connect-agent /bye

AWS credentials in a container

A container gets AWS access only through a devcontainer role, never my IAM user's keys. Once per account, I create that role with its devcontainer-guardrails permissions boundary from .devcontainer/devcontainer-role.cfn.yaml, whose first lines are the deploy command. The boundary allows admin, minus IAM users and groups, identity providers, Organizations and account settings. Roles it creates must carry the same boundary, so every aws_iam_role sets permissions_boundary. What the boundary blocks, I run from the host.

For each project, I set the role in its mise env and point the container at the credentials file:

[env]
DEVCONTAINER_AWS_ROLE_ARN = "arn:aws:iam::<account>:role/devcontainer"
"containerEnv": { "AWS_CONFIG_FILE": "${containerWorkspaceFolder}/.devcontainer/aws/config" }

Then, on the host in the project root, mise run aws-devcontainer assumes the role with my default profile (DEVCONTAINER_AWS_SOURCE_PROFILE picks another) for 12 hours (DEVCONTAINER_AWS_DURATION, in seconds) and writes .devcontainer/aws/, which my global gitignore excludes. When the credentials expire, I run it again; the container picks them up without a restart.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages