2019-04-05 17:22:49 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-04-09 15:14:32 +00:00
|
|
|
#
|
|
|
|
# This script is used by the Makefile to have an implicit nix-shell.
|
|
|
|
#
|
|
|
|
|
2019-04-05 17:22:49 +00:00
|
|
|
GREEN='\033[0;32m'
|
|
|
|
NC='\033[0m'
|
|
|
|
|
|
|
|
export TERM=xterm # fix for colors
|
|
|
|
shift # we remove the first -c from arguments
|
2019-04-09 15:14:32 +00:00
|
|
|
|
2019-04-05 17:22:49 +00:00
|
|
|
if ! command -v "nix" >/dev/null 2>&1; then
|
2019-04-09 15:14:32 +00:00
|
|
|
if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
|
|
|
|
. ~/.nix-profile/etc/profile.d/nix.sh
|
|
|
|
else
|
|
|
|
echo -e "${GREEN}Setting up environment...${NC}"
|
|
|
|
./scripts/setup
|
2019-04-11 12:48:53 +00:00
|
|
|
|
|
|
|
. ~/.nix-profile/etc/profile.d/nix.sh
|
2019-04-09 15:14:32 +00:00
|
|
|
fi
|
2019-04-05 17:22:49 +00:00
|
|
|
fi
|
2019-04-09 15:14:32 +00:00
|
|
|
|
|
|
|
if command -v "nix" >/dev/null 2>&1; then
|
2019-04-12 12:45:54 +00:00
|
|
|
echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}"
|
2019-04-05 17:22:49 +00:00
|
|
|
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
|
2019-04-12 08:36:30 +00:00
|
|
|
exec nix-shell --show-trace --argstr target-os ${TARGET_OS}
|
2019-04-05 17:22:49 +00:00
|
|
|
else
|
2019-04-12 12:45:54 +00:00
|
|
|
is_pure=''
|
|
|
|
[ "${TARGET_OS}" == 'linux' ] && is_pure='--pure'
|
|
|
|
exec nix-shell ${is_pure} --show-trace --argstr target-os ${TARGET_OS} --run "$@"
|
2019-04-05 17:22:49 +00:00
|
|
|
fi
|
|
|
|
fi
|