Skip to content

kc-workspace/dotfiles

Repository files navigation

kc's dotfiles

This is my personal dotfiles (configuration and settings for each program).

Configuration

Below are a list of configuration I have on each categories.

  • Zsh configuration
  • Homebrew packages
    • You can find list of packages here
  • Commandline interface (cli)
    • You can find list of cli here

Prerequisite

  1. Install chezmoi
  2. [Optional] Install gpg for decrypt files (required on full mode)

Get start

Run chezmoi init kc-workspace --apply to initialize and apply config to your machine.

Useful commands

https://www.chezmoi.io/user-guide/daily-operations/ https://www.chezmoi.io/user-guide/command-overview/

Below are a list of useful commands.

To initiate dotfiles on local machine

Similar to update but initiatize new local directories.

sequenceDiagram
  participant T as Target directory
  participant S as Source directory
  participant L as Local repository
  participant R as Remote repository
  R ->> S: pull
  S ->> T: apply (when add --apply)
Loading
## chezmoi init kc-workspace --apply
chezmoi init "<repo>" [--apply]

To update local machine from remote repository

Similar to init but to update existed local directories.

sequenceDiagram
  participant T as Target directory
  participant S as Source directory
  participant L as Local repository
  participant R as Remote repository
  R ->> T: pull & apply
Loading
chezmoi update

To apply state to your local machine

sequenceDiagram
  participant T as Target directory
  participant S as Source directory
  participant L as Local repository
  participant R as Remote repository
  S -> T: diff
  S ->> T: apply
Loading
## View the different between work state and local machine
chezmoi diff
chezmoi apply

To add new file from local machine

sequenceDiagram
  participant T as Target directory
  participant S as Source directory
  participant L as Local repository
  participant R as Remote repository
  T -> S: add [with encrypt (optionally)]
Loading
chezmoi add "<filepath>"
chezmoi add --encrypt "<filepath>"

To remove file from current source

This will only remove file from source directory, not target directory

sequenceDiagram
  participant T as Target directory
  participant S as Source directory
  participant L as Local repository
  participant R as Remote repository
  S -> S: remove file/folder
Loading
chezmoi forget "<filepath>"

Docker

Build docker image

## Without GITHUB_TOKEN environment, mise might failed due to rate-limit exceed
docker buildx build --tag kamontat/dotfiles:local .
## Assume you have $GITHUB_TOKEN environment set
docker buildx build --secret id=GITHUB_TOKEN --tag kamontat/dotfiles:local .

Run docker image

The docker image will contains all applications need for everyday works without secure information. To configure secure information (e.g. gpg, ssh, etc.), run kdf-setup.sh command to fully set up the chezmoi.

The kdf-setup.sh script will verify the result after finished. To verify manually, use kdf-verify.sh script.

## initiate zsh shell session
docker run -it --rm kamontat/dotfiles:local

To verify docker image

All docker image have attestations. You can verify the integrity and provenance of an artifact using its associated cryptographically signed attestations.

The output of the verify command should contains as following information:

  • Verify status: ✓ Verification succeeded!
  • Repository where image was created
  • Workflow and Git Reference where image was created

To verify Docker Hub image:

# gh attestation verify oci://kamontat/dotfiles:latest --owner kc-workspace
$ gh attestation verify "oci://kamontat/dotfiles:<tag-name>" --owner kc-workspace

...
✓ Verification succeeded!
...

To verify GitHub Container Registry image:

## Add read:packages scope to read image from ghcr.
## You may need to login first: https://cli.github.com/manual/gh_auth_login
$ gh auth refresh --scopes "read:packages"

# gh auth token | docker login "ghcr.io" --username "kamontat" --password-stdin
$ gh auth token | docker login "ghcr.io" --username "<username>" --password-stdin

# gh attestation verify "oci://ghcr.io/kc-workspace/dotfiles:latest" --owner kc-workspace
$ gh attestation verify "oci://ghcr.io/kc-workspace/dotfiles:<tag-name>" --owner kc-workspace

...
✓ Verification succeeded!
...