1
0
Fork 0

move to multi-package setup

This commit is contained in:
Luca Bilke 2024-09-25 13:49:24 +02:00
parent 73dc74c5c7
commit c1c20ee5d0
163 changed files with 135 additions and 87 deletions

@ -1 +0,0 @@
Subproject commit 7fed01afba9392b6392408b9a0cf888522ed7a10

14
.gitignore vendored
View File

@ -1,7 +1,7 @@
.config/zsh/.zcompdump
.config/zsh/completions/_kube
.config/zsh/configs/host-setup
.config/nvim/lazyvim.json
.config/nvim/lua/config/secrets.lua
.local/share/xkb/compiled/keymap
.local/share/service/**/supervise/**
common/.config/zsh/.zcompdump
common/.config/zsh/completions/_kube
common/.config/zsh/configs/host-setup
common/.config/nvim/lazyvim.json
common/.config/nvim/lua/config/secrets.lua
common/.local/share/xkb/compiled/keymap
common/.local/share/service/**/supervise/**

4
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule ".config/zsh/plugins/fzf-tab"]
path = .config/zsh/plugins/fzf-tab
[submodule "common/.config/zsh/plugins/fzf-tab"]
path = common/.config/zsh/plugins/fzf-tab
url = https://github.com/Aloxaf/fzf-tab

View File

@ -1,57 +0,0 @@
#!/bin/sh
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
NC="$(tput sgr0)"
mkdir -p "$STOW_DIR/$DOTS_PACKAGE"
# First run
if [ ! -e "$STOW_DIR/$DOTS_PACKAGE/.git" ]; then
printf "%b" "${BOLD}${BLUE}Cloning dotfiles...$NC\n\n"
git clone -j4 --recursive "$DOTS_REPO" "$STOW_DIR/$DOTS_PACKAGE"
stow --no-fold -d "$STOW_DIR" -t "$HOME" "$DOTS_PACKAGE" || printf "%b" "${RED}Failed to run stow!$NC\n"
exit 0
fi
dgit() {
git -C "$STOW_DIR/$DOTS_PACKAGE" "$@"
}
printf "%b" "${BOLD}${BLUE}Removing dotfile symlinks...$NC\n\n"
stow -D -d "$STOW_DIR" -t "$HOME" "$DOTS_PACKAGE" || printf "%b" "${RED}Failed to run stow!$NC\n"
printf "%b" "${BOLD}${BLUE}Stashing existing changes...$NC\n"
stash_result=$(dgit stash push)
needs_pop=1
if [ "$stash_result" = "No local changes to save" ]; then
needs_pop=0
fi
printf "\n"
printf "%b" "${BOLD}${BLUE}Pulling updates from dotfiles repo...$NC\n"
old_commit="$(dgit rev-parse HEAD)"
dgit pull origin main
dgit submodule update --remote --merge
printf "\n"
if [ $needs_pop -eq 1 ]; then
printf "%b" "${BOLD}${BLUE}Popping stashed changes...$NC\n"
dgit stash pop
fi
printf "\n"
unmerged_files=$(dgit diff --name-only --diff-filter=U)
if [ -n "$unmerged_files" ]; then
printf "%b" "${RED}The following files have merge conflicts after popping the stash:$NC\n\n"
printf "%s" "$unmerged_files\n\n"
printf "%s" "${BOLD}${BLUE}Reverting to previous commit...$NC"
dgit checkout "$old_commit"
fi
printf "%b" "${BOLD}${BLUE}Symlinking dotfiles...$NC\n\n"
stow --no-fold -d "$STOW_DIR" -t "$HOME" "$DOTS_PACKAGE" || printf "%b" "${RED}Failed to run stow!$NC\n"
printf "%b" "${BOLD}${GREEN}Dotfiles synced successfully!$NC\n"

View File

@ -1,8 +0,0 @@
README\.md
TODO\.md
\.editorconfig
\.git
\.gitignore
\.gitmodules
\.local/share/service
\.local/share/xkb/compiled/keymap

View File

@ -8,7 +8,7 @@ can use parts of them as well.
I've written a [script](https://github.com/ssnailed/bootstrapper) that will
configure a fresh void installation to be used with these dotfiles. You can
also clone the repo to `~/.local/share/stow/dots` and run
also clone the repo to `~/.local/share/stow` and run
`~/.local/share/stow/dots/.local/bin/dotsync` to install them on an existing
installation, but I'm sure that a few things would break.
@ -16,6 +16,6 @@ installation, but I'm sure that a few things would break.
My [.zprofile](.config/zsh/profile) automatically runs xinit if logged in on
TTY1 and no other X server is running. This is because I use the default
[getty](https://en.wikipedia.org/wiki/Getty_(Unix)) and want to automatically
[getty](<https://en.wikipedia.org/wiki/Getty_(Unix)>) and want to automatically
start dwm after logging in. If any key mappings seem strange, it's because I
use the dvorak keyboard layout.

View File

@ -4,7 +4,7 @@ co $XDG_DOCUMENTS_DIR/dev
dk $XDG_DESKTOP_DIR
dl $XDG_DOWNLOAD_DIR
dm $XDG_DOCUMENTS_DIR
ds $STOW_DIR/$DOTS_PACKAGE
ds $STOW_DIR
dt $XDG_DATA_HOME
e /etc
h $HOME

View File

@ -49,7 +49,7 @@ cmd lazygit ${{
if git --noglob-pathspecs -C $dir status >/dev/null 2>&1; then
lf -remote "send $id \$cd '$dir' && lazygit"
else
lazygit -p "$STOW_DIR/$DOTS_PACKAGE"
lazygit -p "$STOW_DIR"
fi
}}

View File

@ -5,7 +5,7 @@ map gco cd /home/luca/Documents/dev
map gdk cd /home/luca/Desktop
map gdl cd /home/luca/Downloads
map gdm cd /home/luca/Documents
map gds cd /home/luca/.local/share/stow/dots
map gds cd /home/luca/.local/share/stow
map gdt cd /home/luca/.local/share
map ge cd /etc
map gh cd /home/luca

View File

@ -31,7 +31,7 @@ require("lazy").setup({
{ import = "lazyvim.plugins.extras.lang.docker" },
{ import = "lazyvim.plugins.extras.lang.git" },
{ import = "lazyvim.plugins.extras.lang.gleam" },
{ import = "lazyvim.plugins.extras.lang.helm" },
-- { import = "lazyvim.plugins.extras.lang.helm" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.php" },

View File

@ -6,7 +6,7 @@ return {
["<c-a>dk"] = "/home/luca/Desktop",
["<c-a>dl"] = "/home/luca/Downloads",
["<c-a>dm"] = "/home/luca/Documents",
["<c-a>ds"] = "/home/luca/.local/share/stow/dots",
["<c-a>ds"] = "/home/luca/.local/share/stow",
["<c-a>dt"] = "/home/luca/.local/share",
["<c-a>e"] = "/etc",
["<c-a>h"] = "/home/luca",

View File

@ -9,3 +9,4 @@ context.work.write=+work
include /usr/share/doc/task/rc/dark-16.theme
include /usr/share/doc/task/rc/holidays.de-DE.rc
context=work

View File

@ -42,9 +42,9 @@ export LESSOPEN="| /usr/bin/bat -f %s 2>/dev/null"
export ANSIBLE_NOCOWS=1 # Stop those fucking cows in Ansible
# dotfiles management
export DOTS_PACKAGE="dots"
export STOW_DIR="$XDG_DATA_HOME/stow"
export DOTS_REPO="git@git.snaile.de:luca/dotfiles"
export STOW_REPO="git@git.snaile.de:luca/dotfiles"
export STOW_BRANCH="main"
# Color palette for console dialogs in tools such as nmtui and whiptail
export NEWT_COLORS='

View File

@ -58,8 +58,8 @@ workon_cwd() {
if [ -r "$PROJECT_ROOT/.venv" ]; then
local ENV_NAME="$(cat $PROJECT_ROOT/.venv)"
# else
# ENV_NAME="$(basename "$PROJECT_ROOT")"
else
local ENV_NAME="$(basename "$PROJECT_ROOT")"
fi
[ -n "$CD_VIRTUAL_ENV" ] && [ "$ENV_NAME" != "$CD_VIRTUAL_ENV" ] && {

View File

@ -5,7 +5,7 @@ hash -d co=/home/luca/Documents/dev
hash -d dk=/home/luca/Desktop
hash -d dl=/home/luca/Downloads
hash -d dm=/home/luca/Documents
hash -d ds=/home/luca/.local/share/stow/dots
hash -d ds=/home/luca/.local/share/stow
hash -d dt=/home/luca/.local/share
hash -d e=/etc
hash -d h=/home/luca

73
common/.local/bin/dotsync Executable file
View File

@ -0,0 +1,73 @@
#!/bin/sh
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
NC="$(tput sgr0)"
stow_git() {
git -C "$STOW_DIR" "$@"
}
multi_stow() {
ret=0
for package in common "$(hostname)"; do
[ -n "$package" ] && {
stow --no-folding -d "$STOW_DIR" -t "$HOME" "$@" "$package"
ret=$((ret + $?))
}
done
return $ret
}
{ [ -n "$STOW_DIR" ] && [ -n "$STOW_REPO" ] && [ -n "$STOW_BRANCH" ]; } || {
echo "Please set STOW_DIR, STOW_REPO, and STOW_BRANCH"
exit 1
}
mkdir -p "$STOW_DIR"
# First run
if [ ! -e "$STOW_DIR/.git" ]; then
printf "%b" "${BOLD}${BLUE}Cloning dotfiles...$NC\n\n"
git clone -j4 --recursive "$STOW_REPO" "$STOW_DIR"
multi_stow || printf "%b" "${RED}Failed to run stow!$NC\n"
exit 0
fi
printf "%b" "${BOLD}${BLUE}Removing dotfile symlinks...$NC\n\n"
multi_stow -D || printf "%b" "${RED}Failed to run stow!$NC\n"
printf "%b" "${BOLD}${BLUE}Stashing existing changes...$NC\n"
stash_result=$(stow_git stash push)
needs_pop=1
if [ "$stash_result" = "No local changes to save" ]; then
needs_pop=0
fi
printf "\n"
printf "%b" "${BOLD}${BLUE}Pulling updates from dotfiles repo...$NC\n"
old_commit="$(stow_git rev-parse HEAD)"
stow_git pull origin "$STOW_BRANCH"
stow_git submodule update --remote --merge
printf "\n"
if [ $needs_pop -eq 1 ]; then
printf "%b" "${BOLD}${BLUE}Popping stashed changes...$NC\n"
stow_git stash pop
fi
printf "\n"
unmerged_files=$(stow_git diff --name-only --diff-filter=U)
if [ -n "$unmerged_files" ]; then
printf "%b" "${RED}The following files have merge conflicts after popping the stash:$NC\n\n"
printf "%s" "$unmerged_files\n\n"
printf "%s" "${BOLD}${BLUE}Reverting to previous commit...$NC"
stow_git checkout "$old_commit"
fi
printf "%b" "${BOLD}${BLUE}Symlinking dotfiles...$NC\n\n"
multi_stow || printf "%b" "${RED}Failed to run stow!$NC\n"
printf "%b" "${BOLD}${GREEN}Dotfiles synced successfully!$NC\n"

Some files were not shown because too many files have changed in this diff Show More