This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/bin/dotfiles-init

47 lines
1.6 KiB
Plaintext
Raw Normal View History

2023-04-13 14:04:29 -05:00
#!/usr/bin/env bash
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
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")"/../..)"
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
if head /etc/os-release --lines 1 | grep 'Arch Linux' > /dev/null 2>&1; then
sudo pacman -Sy --needed git
fi
git clone https://git.lyte.dev/lytedev/dotfiles.git "$dfp"
2023-04-13 14:04:29 -05:00
fi
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
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"
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"
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