Skip to content

Commit

Permalink
feat: migrate to XDG base directory specification (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
natelandau committed Oct 4, 2024
1 parent b600bbe commit 0d83ae3
Show file tree
Hide file tree
Showing 87 changed files with 447 additions and 346 deletions.
106 changes: 79 additions & 27 deletions .github/workflows/automated_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,21 @@ jobs:
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
mkdir -p ${homedir}/.config/chezmoi
echo '[data]' > ${homedir}/.config/chezmoi/chezmoi.toml
echo ' email = "[email protected]"' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' github_user = "natelandau"' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' dev_computer = false' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' use_secrets = false' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' personal_computer = false' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' homelab_member = false' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' zsh_dir = "${homedir}/.local/share/zsh"' >> ${homedir}/.config/chezmoi/chezmoi.toml
cat > ${homedir}/.config/chezmoi/chezmoi.toml<< EOF
[data]
dev_computer = false
email = "[email protected]"
github_user = "natelandau"
homelab_member = false
is_ci_workflow = true # Set true only in CI test
personal_computer = false
use_secrets = false
xdgCacheDir = "${homedir}/.cache"
xdgConfigDir = "${homedir}/.config"
xdgDataDir = "${homedir}/.local/share"
xdgStateDir = "${homedir}/.local/state"
EOF
# ----------------------------------------------
# Install chezmoi
Expand All @@ -94,60 +101,105 @@ jobs:
- name: Confirm dotfiles are installed
if: startsWith(matrix.os, 'ubuntu')
run: |
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
echo "------- Testing files -------"
cd /home/runner
# echo "pwd: $(pwd)"
# ls -al
existing_files=(
.zshrc
.bashrc
.config/git/config
.ssh/config
.config/dotfile_source/080-linux.sh
.local/share/sed/stopwords.sed
)
missing_files=(
.config/dotfile_source/080-macos.sh
Library
)
installed_packages=(
jq
pygmentize
)
# Confirm files exist
for file in .zshrc .bashrc .gitconfig .shell .ssh/config .shell/sourced/080-linux.sh; do
if [ ! -e $file ]; then
for file in ${existing_files[@]}; do
if [ ! -e "${homedir}/$file" ]; then
echo "$file not found"
exit 1
fi
done
# Confirm files don't exist
for file in Library .shell/sourced/080-macos.sh; do
if [ -e $file ]; then
for file in ${missing_files[@]} ; do
if [ -e "${homedir}/$file "]; then
echo "$file found"
exit 1
fi
done
# Check apt packages
command -v htop 2>&1 >/dev/null || { echo "htop not found"; exit 1; }
# Confirm python packages
command -v pygmentize 2>&1 >/dev/null || { echo "pygmentize not found"; exit 1; }
# Confirm packages are installed
for package in ${installed_packages[@]}; do
if [ ! $(command -v $package) ]; then
echo "$package not found"
exit 1
fi
done
# ----------------------------------------------
# MACOS: Confirm dotfiles are installed
# ----------------------------------------------
- name: Confirm dotfiles are installed
if: startsWith(matrix.os, 'macos')
run: |
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
echo "------- Testing files -------"
cd /Users/runner
cd ${homedir}
existing_files=(
.zshrc
.bashrc
.config/git/config
.config/nano/nanorc
.ssh/config
.config/dotfile_source/080-macos.sh
.local/share/sed/stopwords.sed
)
missing_files=(
.config/dotfile_source/080-linux.sh
)
installed_packages=(
jq
pygmentize
)
# Confirm files exist
for file in .zshrc .bashrc .gitconfig .shell .ssh/config Library .shell/sourced/080-macos.sh; do
if [ ! -e $file ]; then
for file in ${existing_files[@]}; do
if [ ! -e "${homedir}/$file" ]; then
echo "$file not found"
exit 1
fi
done
# Confirm files don't exist
for file in .shell/sourced/080-linux.sh; do
if [ -e $file ]; then
for file in ${missing_files[@]} ; do
if [ -e "${homedir}/$file" ]; then
echo "$file found"
exit 1
fi
done
# Check homebrew packages
command -v htop 2>&1 >/dev/null || { echo "htop not found"; exit 1; }
# Confirm python packages
command -v pygmentize 2>&1 >/dev/null || { echo "pygmentize not found"; exit 1; }
# Confirm packages are installed
for package in ${installed_packages[@]}; do
if [ ! $(command -v $package) ]; then
echo "$package not found"
exit 1
fi
done
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ data.json
.venv
.DS_Store
reports
.mypy_cache
__pycache__
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_stages: [commit, manual]
fail_fast: true
repos:
- repo: "https://github.com/commitizen-tools/commitizen"
rev: v3.29.0
rev: v3.29.1
hooks:
- id: commitizen
- id: commitizen-branch
Expand All @@ -33,7 +33,7 @@ repos:
- id: trailing-whitespace

- repo: "https://github.com/crate-ci/typos"
rev: v1.24.6
rev: v1.25.0
hooks:
- id: typos

Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
".chezmoiremove": "plaintext",
"*.toml.tmpl": "plaintext",
".chezmoiignore": "plaintext"
}
}
4 changes: 3 additions & 1 deletion dotfiles/.assets/iterm2/com.googlecode.iterm2.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@
<key>Columns</key>
<integer>140</integer>
<key>Command</key>
<string>/usr/local/bin/bash</string>
<string></string>
<key>Cursor Color</key>
<dict>
<key>Alpha Component</key>
Expand Down Expand Up @@ -1689,6 +1689,8 @@
<key>Red Component</key>
<real>0.87367779016494751</real>
</dict>
<key>Load Shell Integration Automatically</key>
<true/>
<key>Log Directory</key>
<string></string>
<key>Minimum Contrast</key>
Expand Down
6 changes: 5 additions & 1 deletion dotfiles/.chezmoi.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
email = {{ $email | quote }}
github_user = "natelandau"
homelab_member = {{ $homelab_member }}
is_ci_workflow = false # Set true only in CI test
personal_computer = {{ $personal_computer }}
use_secrets = {{ $use_secrets }}
zsh_dir = "{{ .chezmoi.homeDir }}/.local/share/zsh"
xdgCacheDir = "{{ .chezmoi.homeDir }}/.cache"
xdgConfigDir = "{{ .chezmoi.homeDir }}/.config"
xdgDataDir = "{{ .chezmoi.homeDir }}/.local/share"
xdgStateDir = "{{ .chezmoi.homeDir }}/.local/state"

[diff]
{{ if lookPath "delta" -}}command = "delta"
Expand Down
18 changes: 13 additions & 5 deletions dotfiles/.chezmoidata/onepassword.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
git_stop_words = "op://yc7nim47s6rch4ehrvfsz5icei/vgapmuu57fs3ic44wyupk2orgi/notesPlain"

[secrets]
bws_zoom_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/bws_zoom_link"
calendly_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/calendly"
email_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/default_email"
gitea_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/gitea_url"
zoom_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/zoom_link"
bws_zoom_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/bws_zoom_link"
calendly_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/calendly"
email_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/default_email"
gitea_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/gitea_url"
github_personal_access_token = "op://igqbsqdriuefyzvljd7pom5tum/ikd4inhzvm5pvo2bkyrnkuobh4/personal_access_token"
homebrew_github_token = "op://igqbsqdriuefyzvljd7pom5tum/ikd4inhzvm5pvo2bkyrnkuobh4/homebrew_access_token"
radarr_api_key = "op://igqbsqdriuefyzvljd7pom5tum/yevda4magqej3yawqf573rijd4/api_key"
radarr_url = "op://igqbsqdriuefyzvljd7pom5tum/yevda4magqej3yawqf573rijd4/website"
sonarr_api_key = "op://igqbsqdriuefyzvljd7pom5tum/5zk3pkmm2wbk73ss4dlli6dvz4/api_key"
sonarr_url = "op://igqbsqdriuefyzvljd7pom5tum/5zk3pkmm2wbk73ss4dlli6dvz4/website"
tmdb_api_key = "op://igqbsqdriuefyzvljd7pom5tum/7l5gtxkd23og5wzawz5etq6lju/api_key"
valentina_github_token = "op://igqbsqdriuefyzvljd7pom5tum/ikd4inhzvm5pvo2bkyrnkuobh4/valentina_access_token"
zoom_address = "op://yc7nim47s6rch4ehrvfsz5icei/cq4if4oayozhsfhleijuw6n2aa/zoom_link"
1 change: 1 addition & 0 deletions dotfiles/.chezmoidata/packages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"mas", # Mac App Store command-line interface
"mc", # Midnight Commander
"most", # Pager
"nano",
"ncdu", # NCurses Disk Usage
"ncurses", # Text-based UI library
"openssl", # SSL/TLS cryptography library
Expand Down
24 changes: 17 additions & 7 deletions dotfiles/.chezmoiremove
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
bin/pull_all_repos
.DS_Store

# Migrate to zoxide
.z
# Prepend with a `/` to specify a specific path relative to $HOME.

# Migrate zsh data to ~/.local/share/zsh
.zsh_history
.zfunc/_eza
.zfunc/poetry
# migrate to XDG directories
/.curlrc
/.gitignore
/.gitconfig
/.nanorc
/.lesshst
/.digrc
/.wget-hsts
/.zcompdump
/.python_history
/.local/share/zsh/history
/.sed/htmlDecode.sed
/.sed/htmlEncode.sed
/.sed/stopwords.sed
/.zsh_history
2 changes: 1 addition & 1 deletion dotfiles/.chezmoiscripts/run_after_30-atuin.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if eq .chezmoi.os "linux" -}}
{{- if and (eq .chezmoi.os "linux") (not .is_ci_workflow) -}}
#!/usr/bin/env bash

{{ template "shared_script_utils.bash" . }}
Expand Down
2 changes: 1 addition & 1 deletion dotfiles/.chezmoiscripts/run_after_30-install-eza.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [[ ! $(command -v eza) ]]; then
fi

sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
wget --hsts-file='{{ .xdgDataDir }}/wget-hsts' -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
sudo apt update
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and (eq .chezmoi.os "linux") (.dev_computer) (eq .chezmoi.arch "amd64" ) -}}
{{- if and (eq .chezmoi.os "linux") (.dev_computer) (eq .chezmoi.arch "amd64" ) (not .is_ci_workflow) -}}
#!/usr/bin/env bash

{{ template "shared_script_utils.bash" . }}
Expand Down Expand Up @@ -47,7 +47,7 @@ pushd "${TMP_DIR}" &>/dev/null || exit

DEB="gcm-linux_{{.chezmoi.arch }}.${LATEST_VERSION}.deb"

wget https://github.com/git-ecosystem/git-credential-manager/releases/download/v${LATEST_VERSION}/${DEB}
wget --hsts-file='{{ .xdgDataDir }}/wget-hsts' https://github.com/git-ecosystem/git-credential-manager/releases/download/v${LATEST_VERSION}/${DEB}
sudo dpkg -i "${DEB}"
rm "${DEB}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .is_ci_workflow -}}
#!/usr/bin/env bash
{{ template "shared_script_utils.bash" . }}
{{ $current_os := .chezmoi.os }}
Expand Down Expand Up @@ -62,3 +63,4 @@ uv run -q "${INSTALL_SCRIPT}" --binary-name="{{ $binary.name }}" --repository="{
{{ end }}
{{ end }}
_safeExit_
{{- end }}
20 changes: 11 additions & 9 deletions dotfiles/.chezmoiscripts/run_after_40-install-nanorc.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ if [ ! "$(command -v unzip)" ]; then
fi

# Check if the nano syntax highlighting directory exists
if [ ! -d "${HOME}/.nano" ]; then
header "Installing nano syntax highlighting..."

nano_dir="${HOME}/.nano"
NANO_DIR="{{ .xdgDataDir }}/nano"
if [ ! -e "${NANO_DIR}/conf.nanorc" ]; then
header "Installing nano syntax highlighting..."

mkdir -p "${nano_dir}"
if [ ! -d "${NANO_DIR}" ]; then
mkdir -p "${NANO_DIR}"
fi

wget -O "${nano_dir}/nanorc.zip" https://github.com/scopatz/nanorc/archive/master.zip
wget --hsts-file='{{ .xdgDataDir }}/wget-hsts' -O "${NANO_DIR}/nanorc.zip" https://github.com/scopatz/nanorc/archive/master.zip

pushd "${nano_dir}" >/dev/null || exit
pushd "${NANO_DIR}" >/dev/null || exit

unzip -o "${nano_dir}/nanorc.zip"
mv nanorc-master/* "${nano_dir}/"
unzip -o "${NANO_DIR}/nanorc.zip"
mv nanorc-master/* "${NANO_DIR}/"
rm -rf nanorc-master
rm "${nano_dir}/nanorc.zip"
rm "${NANO_DIR}/nanorc.zip"

popd >/dev/null || exit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{- if lookPath "uv" -}}

#!/usr/bin/env bash

{{ template "shared_script_utils.bash" . }}
Expand Down Expand Up @@ -58,5 +56,3 @@ done
success "Python packages installed"

_safeExit_

{{- end }}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{{- /* Don't run this script in CI, ci username is runner */ -}}
{{- if (and (eq .chezmoi.os "darwin") (ne .chezmoi.username "runner")) -}}
{{- if and (eq .chezmoi.os "darwin") (not .is_ci_workflow) -}}
#!/usr/bin/env bash

{{ template "shared_script_utils.bash" . }}

# Grab the hash of the osx-defaults.sh script to run it when changed
# osx-defaults.sh hash: {{ include "dot_shell/scripts/executable_osx-defaults.sh.tmpl" | sha256sum }}
# osx-defaults.sh hash: {{ include "bin/executable_osx-defaults.sh.tmpl" | sha256sum }}

osx_script=${HOME}/.shell/scripts/osx-defaults.sh
osx_script=${HOME}/bin/osx-defaults.sh
header "Running OS X defaults script"

sudo "${osx_script}"
Expand Down
Loading

0 comments on commit 0d83ae3

Please sign in to comment.