From 1cccb7df0efac654aa9361c7e3d26c06a8f47b01 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Tue, 11 Apr 2023 00:33:39 +0200 Subject: [PATCH] Move mackup's config to $XDG_CONFIG_HOME/mackup - move all of mackup's config files into $XDG_CONFIG_HOME/mackup: + ~/.mackup.cfg => configs for mackup itself + ~/.mackup/*.cfg => custom sync rules applied by mackup - add automatic installation of `pipx` and `mackup` during the setup of the dotfiles + `pipx`'s config is moved into $XDG_CONFIG_HOME + `mackup`s config locations are adapted via a "little hack" --- .config/mackup/README.md | 16 ++++++++++ {.mackup => .config/mackup}/anyconnect.cfg | 0 .config/mackup/gnupg.cfg | 5 ++++ {.mackup => .config/mackup}/histories.cfg | 0 .mackup.cfg => .config/mackup/mackup.cfg | 9 ++++++ {.mackup => .config/mackup}/nautilus.cfg | 0 {.mackup => .config/mackup}/ssh_private.cfg | 0 .local/share/dotfiles/setup.sh | 33 +++++++++++++++++++++ .mackup/README.md | 6 ---- .profile | 5 ++++ 10 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 .config/mackup/README.md rename {.mackup => .config/mackup}/anyconnect.cfg (100%) create mode 100644 .config/mackup/gnupg.cfg rename {.mackup => .config/mackup}/histories.cfg (100%) rename .mackup.cfg => .config/mackup/mackup.cfg (59%) rename {.mackup => .config/mackup}/nautilus.cfg (100%) rename {.mackup => .config/mackup}/ssh_private.cfg (100%) delete mode 100644 .mackup/README.md diff --git a/.config/mackup/README.md b/.config/mackup/README.md new file mode 100644 index 0000000..9fb09de --- /dev/null +++ b/.config/mackup/README.md @@ -0,0 +1,16 @@ +# Configuration for `mackup` + +This folder contains various **config** files + to make [`mackup`](https://github.com/lra/mackup) + synchronize (dot) files the general public should *not* see. +Their format is described [here](https://github.com/lra/mackup/tree/master/doc#add-support-for-an-application-or-almost-any-file-or-directory). + + +## Changed Location + +`mackup`'s default configuration lies the the ~/.mackup.cfg file + and in the ~/.mackup folder that holds config files with + custom sync rules not supported "out of the box." + +With a "little hack" during the setup of the dotfiles in this repository, + `mackup`s config files are moved to $XDG_CONFIG_HOME/mackup. diff --git a/.mackup/anyconnect.cfg b/.config/mackup/anyconnect.cfg similarity index 100% rename from .mackup/anyconnect.cfg rename to .config/mackup/anyconnect.cfg diff --git a/.config/mackup/gnupg.cfg b/.config/mackup/gnupg.cfg new file mode 100644 index 0000000..5d03f48 --- /dev/null +++ b/.config/mackup/gnupg.cfg @@ -0,0 +1,5 @@ +[application] +name = gnupg + +[configuration_files] +.local/share/gnupg/trustdb.gpg diff --git a/.mackup/histories.cfg b/.config/mackup/histories.cfg similarity index 100% rename from .mackup/histories.cfg rename to .config/mackup/histories.cfg diff --git a/.mackup.cfg b/.config/mackup/mackup.cfg similarity index 59% rename from .mackup.cfg rename to .config/mackup/mackup.cfg index 98f9301..0f6a6e7 100644 --- a/.mackup.cfg +++ b/.config/mackup/mackup.cfg @@ -24,3 +24,12 @@ zsh # Do not sync $XDG_DATA_HOME/password-store as it contains symlinks # that Nextcloud does NOT support pass + + +# This section is mainly needed such that this file +# does not cause a ConfigParser error +# => Background: The enclosing folder should only +# contain config files for individual applications +# that are to be synced and not mackup's own config +[application] +name = mackup diff --git a/.mackup/nautilus.cfg b/.config/mackup/nautilus.cfg similarity index 100% rename from .mackup/nautilus.cfg rename to .config/mackup/nautilus.cfg diff --git a/.mackup/ssh_private.cfg b/.config/mackup/ssh_private.cfg similarity index 100% rename from .mackup/ssh_private.cfg rename to .config/mackup/ssh_private.cfg diff --git a/.local/share/dotfiles/setup.sh b/.local/share/dotfiles/setup.sh index b7d2fd6..3b06fca 100755 --- a/.local/share/dotfiles/setup.sh +++ b/.local/share/dotfiles/setup.sh @@ -2,6 +2,7 @@ # such that they are available within a user's $HOME as common "dotfiles" +export XDG_BIN_HOME="$HOME/.local/bin" # temporarily set here; mainly set in ~/.profile export XDG_DATA_HOME="$HOME/.local/share" # temporarily set here; mainly set in ~/.profile @@ -24,6 +25,27 @@ git --git-dir=$XDG_DATA_HOME/dotfiles/ --work-tree=$HOME config --local status.s [ -d "$XDG_DATA_HOME/gnupg" ] && chmod 700 $XDG_DATA_HOME/gnupg +if _command_exists pip; then + + # Ensure `pipx` is installed in the user's local environment + pip install --upgrade --user pipx + + # (Re-)Install `mackup` via `pipx` in the user's local environment + export PIPX_BIN_DIR=$XDG_BIN_HOME + export PIPX_HOME="$XDG_DATA_HOME/pipx" + $XDG_BIN_HOME/pipx uninstall mackup + $XDG_BIN_HOME/pipx install mackup + + # Litte Hack: Make `mackup` respect the XDG directory structure + sed -in 's/VERSION = \".*\"/VERSION = \"0.999.0\"/g' $HOME/.local/**/mackup/constants.py + sed -in 's/CUSTOM_APPS_DIR = \"\.mackup\"/CUSTOM_APPS_DIR = \"\.config\/mackup\"/g' $HOME/.local/**/mackup/constants.py + sed -in 's/MACKUP_CONFIG_FILE = \"\.mackup\.cfg\"/MACKUP_CONFIG_FILE = \"\.config\/mackup\/mackup\.cfg\"/g' $HOME/.local/**/mackup/constants.py + + $XDG_BIN_HOME/mackup restore + +fi + + if _command_exists zsh; then # Set the $ZDOTDIR in /etc[/zsh]/zshenv if that is not already done @@ -60,6 +82,17 @@ fi echo 'Defaults !admin_flag' | sudo tee /etc/sudoers.d/disable_admin_note +# Warn user if ~/.local/pipx already exists +# => As we use the custom $XDG_DATA_HOME/pipx location, +# the user should NOT `pipx`'s default install location as well +if [ -d "$HOME/.local/pipx" ]; then + echo + echo "~/.local/pipx already existed!" + echo "It is recommended to delete this location in favor of $XDG_DATA_HOME/pipx" + echo +fi + + echo echo "Probably it's a good idea to restart the shell" echo "Make sure to start bash or zsh as a login shell the next time" diff --git a/.mackup/README.md b/.mackup/README.md deleted file mode 100644 index 9dff7ee..0000000 --- a/.mackup/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Configuration for `mackup` - -This folder contains various **config** files - to make [`mackup`](https://github.com/lra/mackup) - synchronize (dot) files the general public should *not* see. -Their format is described [here](https://github.com/lra/mackup/tree/master/doc#add-support-for-an-application-or-almost-any-file-or-directory). diff --git a/.profile b/.profile index 1d10320..1aa420a 100644 --- a/.profile +++ b/.profile @@ -11,6 +11,9 @@ export XDG_CACHE_HOME="$HOME/.cache" export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$HOME/.local/share" # also set temporarily in $XDG_DATA_HOME/dotfiles/setup.sh export XDG_STATE_HOME="$HOME/.local/state" # also set temporarily in $XDG_DATA_HOME/dotfiles/setup.sh +# Make up a XDG directory for binaries (that does not exist in the standard) +export XDG_BIN_HOME="$HOME/.local/bin" # also set temporarily in $XDG_DATA_HOME/dotfiles/setup.sh + # Move common tools' config and cache files into XDG directories export BAT_CONFIG_PATH="$XDG_CONFIG_PATH/bat/config" @@ -18,6 +21,7 @@ export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" export GNUPGHOME="$XDG_DATA_HOME/gnupg" export LESSHISTFILE="$XDG_STATE_HOME/less/history" export PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass" +export PIPX_HOME="$XDG_DATA_HOME/pipx" export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc" export PSQLRC="$XDG_CONFIG_HOME/psql/psqlrc" export SSB_HOME="$XDG_DATA_HOME"/zoom @@ -37,6 +41,7 @@ export REPOS="$HOME/repos" # Python-specific configs +export PIPX_BIN_DIR=$XDG_BIN_HOME export PYENV_ROOT="$HOME/.pyenv" # No need for *.pyc files on a dev machine export PYTHONDONTWRITEBYTECODE=1