2023-04-13 14:04:29 -05:00
|
|
|
#!/usr/bin/env bash
|
2020-10-26 16:33:46 -05:00
|
|
|
|
2021-03-25 09:04:51 -05:00
|
|
|
export dfp
|
|
|
|
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
export ENV_PATH="$XDG_CONFIG_HOME/lytedev-env"
|
|
|
|
export CURDIR
|
2020-11-17 17:17:03 -06:00
|
|
|
|
2023-04-13 14:04:29 -05:00
|
|
|
mkdir -p "$ENV_PATH"
|
|
|
|
mkdir -p "$XDG_CONFIG_HOME"
|
2021-03-25 09:04:51 -05:00
|
|
|
dfp="$(realpath "$(dirname "$0")"/../..)"
|
2020-11-07 21:56:10 -06:00
|
|
|
|
2023-04-13 14:04:29 -05:00
|
|
|
# may not be running from inside the dotfiles repo, may have been curl'd down solo, so we need to check
|
|
|
|
if [[ ! -d "$dfp/.git" ]]; then
|
|
|
|
echo "Not running from inside the dotfiles git repo, so we need to download it first!"
|
2023-04-16 02:26:30 -05:00
|
|
|
# each os needs instructions to install git, then we can clone the repo and proceed
|
2023-04-16 02:30:45 -05:00
|
|
|
if ! command -v git; then
|
|
|
|
if head /etc/os-release --lines 1 | grep 'Arch Linux' > /dev/null 2>&1; then
|
|
|
|
if [[ "$EUID" -ne 0 ]]; then
|
|
|
|
if ! command -v sudo; then
|
|
|
|
echo "Error: No sudo command available to try and install 'git'"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
sudo pacman -Sy --needed git
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
pacman -Sy --needed git
|
|
|
|
fi
|
|
|
|
fi
|
2023-04-16 02:26:30 -05:00
|
|
|
fi
|
|
|
|
git clone https://git.lyte.dev/lytedev/dotfiles.git "$dfp"
|
2023-04-13 14:04:29 -05:00
|
|
|
fi
|
2020-11-17 17:17:03 -06:00
|
|
|
|
2023-04-16 02:26:30 -05:00
|
|
|
# auto-link any OS-specific environments
|
2023-04-13 14:04:29 -05:00
|
|
|
if head /etc/os-release --lines 1 | grep 'NixOS$' > /dev/null 2>&1; then
|
|
|
|
ln -s "$dfp/os/linux/nix" "$ENV_PATH/os-linux-nix" > /dev/null 2>&1
|
|
|
|
elif head /etc/os-release --lines 1 | grep 'Arch Linux' > /dev/null 2>&1; then
|
|
|
|
ln -s "$dfp/os/linux/arch" "$ENV_PATH/os-linux-arch" > /dev/null 2>&1
|
|
|
|
fi
|
2020-10-26 16:33:46 -05:00
|
|
|
|
2023-04-16 02:26:30 -05:00
|
|
|
# perform any pre-requisite setup (includes OS-specific setup scripts since we
|
|
|
|
# just included those)
|
2023-04-13 14:04:29 -05:00
|
|
|
for s in "$ENV_PATH"/*; do
|
|
|
|
f="$s/dotfiles-init.d.sh"
|
|
|
|
if [ -f "$f" ]; then
|
|
|
|
echo "dotfiles-init: Running $f..."
|
|
|
|
CURDIR="$s" "$f"
|
2022-02-01 17:10:13 -06:00
|
|
|
fi
|
2023-04-13 14:04:29 -05:00
|
|
|
done
|
2021-03-25 09:04:51 -05:00
|
|
|
|
2023-04-16 02:26:30 -05:00
|
|
|
# perform final dotfiles setup
|
2023-04-13 14:04:29 -05:00
|
|
|
echo "dotfiles-init: Running setup..."
|
|
|
|
"$dfp/common/bin/dotfiles-setup"
|
2020-11-17 17:17:03 -06:00
|
|
|
|
2023-04-16 02:26:30 -05:00
|
|
|
# TODO: setup ssh/gpg keys
|
|
|
|
# TODO: setup password store
|
|
|
|
# TODO: fetch notes database
|
|
|
|
# these are probably best handled in a dotfiles-init.d.sh script in a particular layer
|