2017-11-27 19:40:21 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
########################################################################
|
2017-12-01 17:17:25 +00:00
|
|
|
# This install script will setup your development dependencies on OS X
|
2019-04-05 17:22:49 +00:00
|
|
|
# or Ubuntu. Ubuntu 18.04 is the only tested version.
|
2019-05-07 15:57:30 +00:00
|
|
|
# It is not required or supported in NixOS.
|
2017-11-27 19:40:21 +00:00
|
|
|
#
|
2017-12-01 17:17:25 +00:00
|
|
|
# Usage: scripts/setup
|
2017-11-27 19:40:21 +00:00
|
|
|
########################################################################
|
|
|
|
|
|
|
|
_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
|
2017-12-01 17:17:25 +00:00
|
|
|
source "$_current_dir/lib/setup/path-support.sh"
|
2017-11-27 19:40:21 +00:00
|
|
|
|
|
|
|
source_lib "output.sh"
|
|
|
|
source_lib "packages.sh"
|
|
|
|
source_lib "platform.sh"
|
|
|
|
|
2017-12-01 17:17:25 +00:00
|
|
|
exit_unless_os_supported
|
2017-11-27 19:40:21 +00:00
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
####
|
|
|
|
setup_header "Checking prerequisites..."
|
|
|
|
|
2019-05-06 13:16:31 +00:00
|
|
|
_need_curl=0
|
|
|
|
! is_nixos && ! program_exists nix && _need_curl=1
|
|
|
|
|
|
|
|
if _need_curl && ! program_exists "curl"; then
|
2019-02-01 10:44:51 +00:00
|
|
|
cecho "@b@yellow[[Please install curl before running setup.]]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-02-28 10:56:58 +00:00
|
|
|
if is_linux && [ -z "$CI_ENVIRONMENT" ]; then
|
2019-02-01 10:44:51 +00:00
|
|
|
watches=$(cat /proc/sys/fs/inotify/max_user_watches)
|
|
|
|
required_watches=524288
|
|
|
|
if [ $watches -lt $required_watches ]; then
|
|
|
|
cecho "@b@cyan[[fs.inotify.max_user_watches limit is too low ($watches), increasing it]]"
|
|
|
|
echo fs.inotify.max_user_watches=$required_watches | sudo tee -a /etc/sysctl.conf
|
|
|
|
sudo sysctl -p
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "/etc/arch-release" ]; then
|
|
|
|
# Arch Linux
|
|
|
|
userns=$(sysctl -n kernel.unprivileged_userns_clone)
|
|
|
|
if [ "$userns" != '1' ]; then
|
|
|
|
sudo sysctl kernel.unprivileged_userns_clone=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-11-27 19:40:21 +00:00
|
|
|
####
|
|
|
|
setup_header "Installing requirements..."
|
|
|
|
|
2019-05-06 13:16:31 +00:00
|
|
|
if [ "$IN_NIX_SHELL" != 'pure' ] && ! is_nixos && ! program_exists nix; then
|
2019-04-11 12:48:53 +00:00
|
|
|
required_version=$(toolversion nix)
|
|
|
|
NIX_INSTALLER_NO_MODIFY_PROFILE=1 bash <(curl https://nixos.org/releases/nix/nix-${required_version}/install) --no-daemon
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo -e "${YELLOW}**********************************************************************************************************"
|
|
|
|
echo "The Nix package manager was successfully installed."
|
|
|
|
echo -e "**********************************************************************************************************${NC}"
|
|
|
|
else
|
|
|
|
echo "Please see https://nixos.org/nix/manual/#chap-installation"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
2017-11-27 19:40:21 +00:00
|
|
|
|
|
|
|
####
|
|
|
|
setup_complete
|