dotfiles/install.sh
2025-03-11 13:48:35 +00:00

61 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install my dotfiles on a variety of systems
set -ex
echo "PWD: $PWD"
# Coder dotfiles (and most other ways of doing this) will not do a recursive clone, so do that in install script.
git submodule init && git submodule update
# Match case insensitively to make things easier for this part
shopt -s nocasematch
echo "Installing dotfiles..."
if [ "${CODER_TEMPLATE_TYPE}" == "Devcontainer" ]; then
installers/install-nix.sh
installers/install-nix-packages-flake.sh
. ~/.nix-profile/etc/profile.d/nix.sh
elif [ "${CODER_OS_FAMILY:-}" == "Ubuntu" ]; then
echo "Detected OS as Ubuntu, using apt";
sudo apt-get update;
sudo apt-get install -y stow;
installers/install-nix.sh
. ~/.nix-profile/etc/profile.d/nix.sh
elif [ -f /etc/os-release ]; then
echo "Idenitfying OS to install GNU stow..."
if grep -q -i debian /etc/os-release; then
echo "Detected OS as Ubuntu, using apt";
sudo apt-get update;
sudo apt-get install -y stow;
elif grep -q -i rhel /etc/os-release || grep -q -i fedora /etc/os-release; then
echo "You've got RedHat (or maybe Fedora)! Which is unsupported right now sorry!";
# sudo yum install -y stow;
# sudo yum clean all;
exit 1
elif grep -q -i alpine /etc/os-release; then
echo "You've got Alpine! Which is unsupported right now sorry!";
exit 1;
# apk add --no-cache jq curl;
else
echo "ERROR: Unable to identify OS!" 1>&2;
exit 1;
fi;
else
echo "ERROR: Unable to find '/etc/os-release' information!" 1>&2;
exit 1;
fi
shopt -u nocasematch
# Apply the dotfiles with stow
echo "Running apply dotfiles"
if which stow &> /dev/null; then
./apply-dotfiles
elif which nix &> /dev/null; then
./apply-dotfiles-nix
else
echo "Tools for installing dotfiles are unavailable, failing..."
exit 1
fi
echo "Dotfiles applied successfully"