diff --git a/.gitignore b/.gitignore index 5e1422c..0335b82 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ build-iPhoneSimulator/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc +/.idea diff --git a/README.md b/README.md index b32293f..c2110e5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # bambrew + Bambrew - Bamboo Engineering's development environment setup tooling -# First time setup +# Mac First time setup 1. Ask an existing `bambooengineering/umbrella` administrator to grant you repo access 1. Setup a GitHub [personal access token][1] @@ -11,4 +12,31 @@ Bambrew - Bamboo Engineering's development environment setup tooling sh -c "$(curl -fsSL https://github.com/bambooengineering/bambrew/raw/master/run_bamstrap)" ``` +# Linux first time setup + +Linux setup is largely done with Nix home-manager (not full NixOS). The steps below amount to +setting up home-manager, git and getting a checkout of the main repo. After that, it is all a script +in that repo. + +The script in this repo will achieve that. The steps are: + +1. Run this to get `home-manager` and the main repo ready: + ```bash + SILVERCAT_GIT_CHECKOUTS_DIR= ~/code/gh/bambooengineering sudo sh -c "$(curl -fsSL https://github.com/bambooengineering/bambrew/raw/master/run_bamstrap_linux)" + ``` +2. Add this to the top of your `~/.config/home-manager/home.nix` file: + ```nix + imports = [ + /home//.umbrella/bambrew/assets/nix/silvercat.nix + ]; + ``` +3. Run the following command to install the silvercat `home-manager` packages and system utilities. + Note, this is idempotent and should be quick once completed the first time. You should run it + regularly. + ```bash + ~/.umbrella/bambrew/scripts/setup.sh + ``` + +That's it. Read the bambrew docs on starting up the development environment. + [1]: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line diff --git a/run_bamstrap_linux b/run_bamstrap_linux new file mode 100755 index 0000000..dc6b498 --- /dev/null +++ b/run_bamstrap_linux @@ -0,0 +1,63 @@ +#!/bin/bash + +set -e + +if [ "$(id -u)" = 0 ]; then + echo "Aborting! Must not be run as root" + exit 4 +fi + +if [ -z "$USER" ]; then + echo "Aborting! No USER environment variable set" + exit 3; +fi + +if [ -z "$SILVERCAT_GIT_CHECKOUTS_DIR" ]; then + echo "Aborting! No SILVERCAT_GIT_CHECKOUTS_DIR environment variable set" + echo "Set it to any directory where you want to clone all Silvercat repos." + echo "For example: export SILVERCAT_GIT_CHECKOUTS_DIR=~/code/gh/bambooengineering" + exit 3; +fi + +if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then + if [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then + echo "Ensure you have your GitHub SSH key at ~/.ssh/id_rsa.pub or ~/.ssh/id_ed25519.pub" + exit 1 + fi +fi + +if [ ! -d "nix" ]; then + echo "Installing nix..." + sh <(curl -L https://nixos.org/nix/install) --daemon + echo "Done installing nix! Open a new shell then run this script again." + exit 1 +fi + +if [ -x "$(command -v home-manager)" ]; then + echo "Installing home-manager..." + nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager + nix-channel --update + nix-shell '' -A install + home-manager switch + + echo "Now you must set up your machine to clone GitHub repos. You can do this one of two ways: + + 1. Copy your ssh key into /home//.ssh. Typically, this is your ~/.ssh/id_ed25519 file. + You may need a USB key for this. + You can also run this to add your passphrase to the ssh-agent: + ssh-add ~/.ssh/id_ed25519 + 2. Use gh as installed above and run: gh auth login + This will then prompt you to authenticate with github, which you can do via the browser." + + echo "After you have done that, run this script again." + exit 1 +fi + +if [ ! -d "~/.umbrella" ]; then + echo "Cloning umbrella into $SILVERCAT_GIT_CHECKOUTS_DIR..." + mkdir -p "$SILVERCAT_GIT_CHECKOUTS_DIR" + nix shell -p git -c "git clone git@github.com:bambooengineering/umbrella.git $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella" + ln -s "$SILVERCAT_GIT_CHECKOUTS_DIR/umbrella" ~/.umbrella +fi + +echo "Completed checkout. Now add the silvercat.nix to your home-manager config and "