Skip to content

Commit

Permalink
Install with stow
Browse files Browse the repository at this point in the history
  • Loading branch information
Jendker committed Sep 25, 2024
1 parent f97ca59 commit 9702f24
Show file tree
Hide file tree
Showing 42 changed files with 144 additions and 93 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ jobs:
token: ${{ secrets.PAT }}
submodules: true

- name: Run setup
- name: Test setup
run: |
./install.sh
if [[ "$RUNNER_OS" == "Linux" ]]; then
./set_up_debian.sh
./set_up_debian_dev.sh --optional
elif [[ "$RUNNER_OS" == "macOS" ]]; then
./macos/install.sh
./macos/set_defaults.sh --optional
fi
./scripts/install.sh
./scripts/uninstall.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nvim/lua/machine_settings.lua
common/.config/nvim/lua/machine_settings.lua
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion nvim/lazy-lock.json → common/.config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
"quicker.nvim": { "branch": "master", "commit": "183041a46d6c908eefb1c23ea02cce9c8f41256e" },
"render-markdown.nvim": { "branch": "main", "commit": "0986638b381a4b01eb108bb946f3a67a9eb3d0ec" },
"render-markdown.nvim": { "branch": "main", "commit": "67288febca78b7aac8fae9543ef8980237e27d2a" },
"spaceless.nvim": { "branch": "main", "commit": "8d46bc098dba18d4e19bce89bf19aab5007ef767" },
"stickybuf.nvim": { "branch": "master", "commit": "183b9569bef78f44b17c078214f7d731f19cbefe" },
"substitute.nvim": { "branch": "main", "commit": "17ffaeb5a1dc2dbef39cf0865d8a4b6000836714" },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 8 additions & 2 deletions .wezterm.lua → common/.wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ config.font_size = 11
if wezterm.target_triple == 'aarch64-apple-darwin' then
config.window_close_confirmation = 'NeverPrompt'
config.window_decorations = "RESIZE"
config.font = wezterm.font{
local weight = "Medium"
config.font_size = 12
if wezterm.hostname() == "Jedrzejs-Mac-mini.local" then
config.font_size = 13
weight = "Bold"
end
config.font = wezterm.font {
family = 'Monaco Nerd Font',
harfbuzz_features = { 'ss07', 'calt', 'liga=0' },
weight = weight,
}
config.font_size = 12
config.native_macos_fullscreen_mode = true
else
-- disable the window title bar
Expand Down
1 change: 1 addition & 0 deletions debian/clangd
2 changes: 1 addition & 1 deletion dotfiles_private
53 changes: 0 additions & 53 deletions install.sh

This file was deleted.

17 changes: 17 additions & 0 deletions macos/.unison/default.prf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# roots define root directories for syncing between
root = /Users/jedrzej/Library/Mobile Documents/iCloud~md~obsidian/Documents/
root = /Users/jedrzej/Dropbox/ObsidianVaults/

# dirs to sync
path=Personal

# don't ask for confirmation
auto=true
batch=true
# sync ownership and group
owner=true
group=true
# for safety
confirmbigdel=true
# prefer newer in case of conflicts
prefer=newer
1 change: 1 addition & 0 deletions macos/Library/Preferences/clangd
File renamed without changes.
4 changes: 2 additions & 2 deletions set_up_debian_dev.sh → scripts/debian/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -e

SCRIPT_DIR=$(dirname "$0")
ROOT_DIR=$(realpath "${SCRIPT_DIR}/../..")

# Initialize a flag
optional_provided=false
Expand All @@ -19,15 +20,14 @@ function setup_nerdfont() {
git clone https://github.com/epk/SF-Mono-Nerd-Font.git /tmp/SF-Mono-Nerd-Font
cp /tmp/SF-Mono-Nerd-Font/*.otf ~/.local/share/fonts/
rm -rf /tmp/SF-Mono-Nerd-Font
cp "$SCRIPT_DIR"/dotfiles_private/fonts/* ~/.local/share/fonts/
cp "$ROOT_DIR"/dotfiles_private/fonts/* ~/.local/share/fonts/
rm ~/.local/share/fonts/MonacoNerdFont-Regular.ttf
fc-cache -f
}

function setup_powerlevel10k() {
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" || true
sed -i 's/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"powerlevel10k\/powerlevel10k\"/g' "$HOME/.zshrc"
cp "$SCRIPT_DIR/.p10k.zsh" "$HOME/"
}

function setup_sublimetext() {
Expand Down
6 changes: 3 additions & 3 deletions set_up_debian.sh → scripts/debian/install_min.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

function get_highest_tag_version() {
git tag | sort -V | tail -n 1
}
Expand Down Expand Up @@ -265,7 +267,7 @@ ln -s $(which fdfind) $HOME/.local/bin/fd || true
sudo apt install ripgrep -y || true

# run set_up_common.sh
./set_up_common.sh
"$SCRIPT_DIR/../set_up_common.sh"

if command -v doit &>/dev/null; then
pipx install thefuck
Expand Down Expand Up @@ -338,5 +340,3 @@ install_direnv
install_delta

install_gh

echo "Done"
72 changes: 72 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

set -x
set -e

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ROOT_DIR=$(dirname "$SCRIPT_DIR")

copy=false
if [[ $1 == "--copy" ]]; then
copy=true
fi

function add() {
rm -r "$2" || true
if [[ $copy == true ]]; then
cp -r "$1" "$2"
else
ln -s "$1" "$2"
fi
}

# snippets
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
vscode_snippets_path="$HOME/.config/Code/User/snippets"
elif [[ "$OSTYPE" == "darwin"* ]]; then
vscode_snippets_path="$HOME/Library/Application Support/Code/User/snippets"
else
echo "OS type unknown. Exiting."
exit 1
fi
mkdir -p "$(dirname "${vscode_snippets_path}")"
add "$SCRIPT_DIR/nvim/snippets" "${vscode_snippets_path}"

cd "$ROOT_DIR"

if ! [ -x "$(command -v stow)" ]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt install stow -y
elif [[ "$OSTYPE" == "darwin"* ]]; then
if ! [ -x "$(command -v brew)" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install stow
else
echo "Unsupported OS"
fi
fi

# Stow common config
stow -t ~ common
cd dotfiles_private/stow
stow -t ~ common_private
cd ../..

# Stow platform-specific config
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
stow -t ~ debian
cd dotfiles_private/stow
stow -t ~ debian_private
cd ../..
scripts/debian/install_min.sh
scripts/debian/install.sh --optional
elif [[ "$OSTYPE" == "darwin"* ]]; then
stow -t ~ macos
cd dotfiles_private/stow
stow -t ~ macos_private
cd ../..
scripts/macos/install.sh
else
echo "Unsupported OS"
fi
12 changes: 6 additions & 6 deletions macos/install.sh → scripts/macos/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
set -e

SCRIPT_DIR=$(dirname $0)
ROOT_DIR=$(dirname "$SCRIPT_DIR")
ROOT_DIR=$(realpath "${SCRIPT_DIR}/../..")

$ROOT_DIR/set_up_common.sh
$SCRIPT_DIR/../set_up_common.sh

KEYBOARD_SOURCE_PATH="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Random/Keyboard Layouts/Polish-German.bundle"
KEYBOARD_TARGET_PATH="$HOME/Library/Keyboard Layouts/Polish-German.bundle"
Expand All @@ -20,7 +20,7 @@ if ! grep -Fxq "PasswordAuthentication no" "$SSH_CONFIG_PATH"; then
echo "ChallengeResponseAuthentication no" | sudo tee -a "$SSH_CONFIG_PATH"
fi

# karabiner config
rm "$HOME/.config/karabiner.edn"
ln -s "$ROOT_DIR/dotfiles_private/karabiner.edn" "$HOME/.config/karabiner.edn"
goku || echo "goku not installed. Install with brew and run 'goku' when possible."
# run goku to install karabiner config
goku > /dev/null || echo "goku not installed. Install with brew and run 'goku' when possible."

$SCRIPT_DIR/set_defaults.sh
3 changes: 3 additions & 0 deletions macos/set_defaults.sh → scripts/macos/set_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# General UI/UX #
###############################################################################

echo "Disabling startup sound effects, password will be required"
# Disable the sound effects on boot
set -x
sudo nvram StartupMute=%01
set +x

# Disable crash report windows
# https://stackoverflow.com/questions/6084497/silencing-osx-crash-report-window
Expand Down
5 changes: 2 additions & 3 deletions set_up_common.sh → scripts/set_up_common.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash
set -e

if [ -d ~/.oh-my-zsh ]; then
echo "oh-my-zsh is installed"
else
echo "installing oh-my-zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
echo "Changing default shell, password required"
sudo chsh -s "$(which zsh)" "$(whoami)" || true
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/zsh-syntax-highlighting
git clone https://github.com/MenkeTechnologies/zsh-expand.git "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/zsh-expand
Expand All @@ -18,9 +20,6 @@ git config --global pull.rebase true
git config --global user.name "Jedrzej Orbik"
git config --global user.email [email protected]

# copy the aliases
SCRIPT_DIR=$(dirname "$0")
cp "$SCRIPT_DIR/.aliases" ~/.aliases
grep -qF 'source ~/.aliases' "$HOME/.zshrc" || echo '[ -e ~/.aliases ] && source ~/.aliases' >>"$HOME/.zshrc"
grep -qxF 'eval "$(direnv hook zsh)"' "$HOME"/.zshrc || echo 'eval "$(direnv hook zsh)"' >>"$HOME/.zshrc"
mkdir -p ~/.config/direnv
Expand Down
23 changes: 23 additions & 0 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e

# Unstow platform-specific config
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
cd dotfiles_private/stow
stow -D -t ~ debian_private
cd ../..
stow -D -t ~ debian
elif [[ "$OSTYPE" == "darwin"* ]]; then
cd dotfiles_private/stow
stow -D -t ~ macos_private
cd ../..
stow -D -t ~ macos
else
echo "Unsupported OS"
fi

# Unstow common
cd dotfiles_private/stow
stow -D -t ~ common_private
cd ../..
stow -D -t ~ common
12 changes: 0 additions & 12 deletions uninstall.sh

This file was deleted.

0 comments on commit 9702f24

Please sign in to comment.