mirror of
https://github.com/caperren/nixos-configs.git
synced 2025-11-08 19:51:14 +00:00
Added initial_setup.sh for setup bootstrapping
This commit is contained in:
40
initial_setup.sh
Executable file
40
initial_setup.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# To set up a fresh system, run the following:
|
||||
# curl -sSL https://raw.githubusercontent.com/caperren/nixos-configs/main/initial_setup.sh | bash
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||
|
||||
GIT_REPO_NAME="nixos-configs"
|
||||
GIT_RELEASE_BRANCH="playground"
|
||||
GIT_REPO_URL="git@github.com:caperren/$GIT_REPO_NAME.git"
|
||||
|
||||
NIXOS_REPO_CONFIG_PARENT_PATH="/opt"
|
||||
NIXOS_REPO_CONFIG_PATH="$NIXOS_REPO_CONFIG_PARENT_PATH/$GIT_REPO_NAME"
|
||||
HOST_CONFIG_PATH="$NIXOS_REPO_CONFIG_PATH/hosts/$(hostname)"
|
||||
|
||||
# If the config repo doesn't exist, clone it
|
||||
if [ ! -d "$NIXOS_REPO_CONFIG_PATH" ]; then
|
||||
TEMP_CLONE_DIR="/home/$USER/$GIT_REPO_NAME"
|
||||
|
||||
if [[ ! -d "$NIXOS_REPO_CONFIG_PARENT_PATH" ]]; then
|
||||
sudo mkdir -p "$NIXOS_REPO_CONFIG_PARENT_PATH"
|
||||
fi
|
||||
|
||||
git clone "$GIT_REPO_URL" "$TEMP_CLONE_DIR" || true
|
||||
|
||||
sudo mv "$TEMP_CLONE_DIR" "$NIXOS_REPO_CONFIG_PARENT_PATH/."
|
||||
cd "$NIXOS_REPO_CONFIG_PATH"
|
||||
|
||||
git checkout "$GIT_RELEASE_BRANCH"
|
||||
|
||||
sudo chown -R $USER:users "$NIXOS_REPO_CONFIG_PATH"
|
||||
fi
|
||||
|
||||
# If we're not running from the repo directory, this script launch is a setup bootstrap
|
||||
# Exec the same script in the config repo, which should be the right one for the release branch
|
||||
# we want
|
||||
if [[ "$SCRIPT_DIR" != "$NIXOS_REPO_CONFIG_PATH" ]]; then
|
||||
exec "$NIXOS_REPO_CONFIG_PATH/initial_setup.sh"
|
||||
exit
|
||||
fi
|
||||
Reference in New Issue
Block a user