daml/dev-env/bin/dade-init
Digital Asset GmbH 05e691f558 open-sourcing daml
2019-04-04 09:33:38 +01:00

54 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Idempotent initialization for DADE
# Installs nix and prepares some common tools
#
DADE_CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ "$DADE_CURRENT_SCRIPT_DIR" =~ ^/nix/store/.* ]]; then
echo "Unable to init dev-env from Nix store. Are you running this from another repository than `da`?"
exit 1
fi
DADE_REPO_ROOT="$( cd $DADE_CURRENT_SCRIPT_DIR/../../ && pwd )"
unset NIX_CONF_DIR
unset NIX_PATH
set -Eeuo pipefail
error() {
echo "dade-init failed at ${1:-UNSET}: ${2:-UNSET}"
echo "nix install log:"
cat /tmp/dade-nix-install.log
}
trap 'error ${LINENO}' ERR
# 1. Make sure nix is installed properly
# shellcheck source=../lib/ensure-nix
source "$DADE_CURRENT_SCRIPT_DIR/../lib/ensure-nix"
# Bootstrap our nixpkgs snapshot by loading the profile
bash $DADE_REPO_ROOT/dev-env/profile_bash.sh
# 2. Install our git-hooks
bash $DADE_REPO_ROOT/dev-env/bin/da-install-git-hooks
# n. Notify
echo "=========================================================================="
echo
echo "dade-init completed."
echo
echo 'PREFERRED: Please install https://direnv.net/ and do `direnv allow` in this repo.'
echo
echo "Fallback mechanism:"
echo " Add 'source ${DADE_REPO_ROOT}/dev-env/profile_bash.sh' to your bash profile"
echo " or 'source ${DADE_REPO_ROOT}/dev-env/profile_zsh.sh' to your zsh profile"
echo
echo ' and run it in your current shell to expose the DA dev-env tools on your $PATH.'
echo
echo "Optionally you can run 'dade-preload' to eagerly load all the dev-env tools."
echo "=========================================================================="