Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec4c0437c4 | ||
|
|
908936c360 | ||
|
|
f5f7acacb6 | ||
|
|
d324c13f02 | ||
|
|
1717fd0ef0 | ||
|
|
857465ccd9 |
@@ -89,6 +89,7 @@ if [[ -d ${HOME}/bin ]]; then
|
||||
export PATH=$PATH:${HOME}/bin
|
||||
fi
|
||||
|
||||
eval "$(mise activate bash)"
|
||||
|
||||
# Enable atuin
|
||||
# https://docs.atuin.sh
|
||||
|
||||
+72
-7
@@ -13,18 +13,67 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
link_shell_configs() {
|
||||
# Manually create the symlinks that `stow` would create for the shell
|
||||
# configs, without needing `stow`. This solves the chicken-and-egg problem
|
||||
# below: `brew` is not on the PATH until these configs are in place, but
|
||||
# `stow` is installed with `brew`.
|
||||
#
|
||||
# The link targets are relative and route through ~/.dotfiles. Note that
|
||||
# stow resolves that symlink to its physical path, so it does NOT
|
||||
# recognize these as its own -- ./run-stow.sh reports them as conflicts
|
||||
# ("existing target is not owned by stow") and aborts the whole run.
|
||||
# Remove them before stowing if you want stow to manage them instead.
|
||||
if [ ! -d "${HOME}/.dotfiles" ]; then
|
||||
echo "Cannot find dotfiles directory in user home." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
link_config() {
|
||||
local link="$1" # path to create, relative to ${HOME}
|
||||
local target="$2" # link contents, relative to the link's directory
|
||||
|
||||
# Only ever create a missing link. Anything already at this path -- a
|
||||
# link stow made, a link from a previous run, or a real file the user
|
||||
# wrote -- is left exactly as it is.
|
||||
if [ -e "${HOME}/${link}" ] || [ -L "${HOME}/${link}" ]; then
|
||||
echo "~/${link} already exists, leaving it alone"
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "${HOME}/${link}")"
|
||||
ln -s "${target}" "${HOME}/${link}"
|
||||
echo "Linked ~/${link} -> ${target}"
|
||||
}
|
||||
|
||||
link_config .bashrc .dotfiles/home/.bashrc
|
||||
link_config .config/fish ../.dotfiles/home/.config/fish
|
||||
}
|
||||
|
||||
require_sudo() {
|
||||
# Both the distro package managers and the homebrew installer need sudo.
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo "sudo is not installed or not on the PATH." >&2
|
||||
echo "Become root (su -) and run visudo to temporarily grant this user" >&2
|
||||
echo "passwordless sudo:" >&2
|
||||
echo >&2
|
||||
echo " $(id -un) ALL=(ALL) NOPASSWD: ALL" >&2
|
||||
echo >&2
|
||||
echo "Re-run this script, then remove that line with visudo when done." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
install_common() {
|
||||
# Packages installed on every machine (desktop and headless server).
|
||||
|
||||
require_sudo
|
||||
|
||||
# Install homebrew dependencies (dnf on Fedora, apt on Debian/Ubuntu).
|
||||
if command -v dnf >/dev/null 2>&1; then
|
||||
sudo dnf group install development-tools
|
||||
elif command -v apt-get >/dev/null 2>&1; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential procps curl file git
|
||||
else
|
||||
echo "No supported package manager (dnf/apt-get) found for homebrew deps" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
@@ -34,6 +83,20 @@ install_common() {
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
fi
|
||||
|
||||
# NOTE: Chicken-and-egg issue. `brew` is not on the path until we run
|
||||
# `stow`, but we install `stow` with `brew`. Link the shell configs by
|
||||
# hand so the rest of this script (and new shells) can find `brew`.
|
||||
link_shell_configs
|
||||
|
||||
# The shell configs above put brew on the PATH for new shells, but this
|
||||
# already-running shell won't pick it up. Nothing below works without it.
|
||||
if ! command -v brew >/dev/null 2>&1; then
|
||||
echo "brew is not on the PATH." >&2
|
||||
echo "The shell configs have been linked, so log out and back in (or start" >&2
|
||||
echo "a new shell) to refresh the PATH, then re-run this script." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# NOTE: Do not brew install anything with a dependency on node.
|
||||
# Instead, use mise.
|
||||
#
|
||||
@@ -97,6 +160,8 @@ install_common() {
|
||||
}
|
||||
|
||||
install_desktop() {
|
||||
require_sudo
|
||||
|
||||
# Install flatpaks
|
||||
flatpak install flathub com.github.jeromerobert.pdfarranger
|
||||
flatpak install flathub fr.handbrake.ghb
|
||||
@@ -148,7 +213,7 @@ install_server() {
|
||||
#
|
||||
# NOTE: Debian may lack the tmux-256color terminfo entry (it's in the
|
||||
# ncurses-term package); install it if tmux complains about the terminal.
|
||||
:
|
||||
sudo apt install -y bubblewrap
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
Reference in New Issue
Block a user