prevent nix setup running multiple times

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-04-09 17:14:32 +02:00
parent 3230f00c6c
commit 7b309d4875
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 18 additions and 8 deletions

View File

@ -1,19 +1,29 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# This script is used by the Makefile to have an implicit nix-shell.
#
GREEN='\033[0;32m' GREEN='\033[0;32m'
NC='\033[0m' NC='\033[0m'
export TERM=xterm # fix for colors export TERM=xterm # fix for colors
shift # we remove the first -c from arguments shift # we remove the first -c from arguments
if ! command -v "nix" >/dev/null 2>&1; then if ! command -v "nix" >/dev/null 2>&1; then
echo -e "${GREEN}Setting up environment...${NC}" if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
./scripts/setup . ~/.nix-profile/etc/profile.d/nix.sh
fi
if command -v "nix" >/dev/null 2>&1 || [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
echo -e "${GREEN}Configuring Nix shell...${NC}";
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
. ~/.nix-profile/etc/profile.d/nix.sh && exec nix-shell
else else
. ~/.nix-profile/etc/profile.d/nix.sh && exec nix-shell --run "$@" echo -e "${GREEN}Setting up environment...${NC}"
./scripts/setup
fi
fi
if command -v "nix" >/dev/null 2>&1; then
echo -e "${GREEN}Configuring Nix shell...${NC}";
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
exec nix-shell
else
exec nix-shell --run "$@"
fi fi
fi fi