2020-02-19 13:15:28 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# This script makes sure we have Nix tools available
|
|
|
|
|
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
|
|
|
|
2020-05-04 16:32:47 +00:00
|
|
|
# Location of profile script for Nix that adjusts PATH
|
|
|
|
NIX_PROFILE_SH="${HOME}/.nix-profile/etc/profile.d/nix.sh"
|
|
|
|
|
2020-02-19 13:15:28 +00:00
|
|
|
function source_nix() {
|
|
|
|
# Just stop if Nix is already available
|
|
|
|
if [[ -x $(command -v nix) ]]; then
|
|
|
|
return
|
2020-05-04 16:32:47 +00:00
|
|
|
elif [[ -f "${NIX_PROFILE_SH}" ]]; then
|
2020-02-19 13:15:28 +00:00
|
|
|
# Load Nix profile if it exists
|
2020-05-04 16:32:47 +00:00
|
|
|
source "${NIX_PROFILE_SH}"
|
|
|
|
return
|
2020-02-19 13:15:28 +00:00
|
|
|
else
|
|
|
|
# Setup Nix if not available
|
|
|
|
${GIT_ROOT}/nix/scripts/setup.sh
|
|
|
|
fi
|
|
|
|
|
2020-05-04 16:32:47 +00:00
|
|
|
# Load Nix profile
|
|
|
|
source "${NIX_PROFILE_SH}"
|
|
|
|
|
2020-02-19 13:15:28 +00:00
|
|
|
# Verify Nix is available
|
|
|
|
if [[ ! -x $(command -v nix) ]]; then
|
|
|
|
echo "Nix not available, sourcing profile failed!" > /dev/stderr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
source_nix
|