Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ build-iPhoneSimulator/

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
/.idea
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -11,4 +12,68 @@ 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.

1. Start by installing Nix home-manager. At time of writing, the following command should work. It
first installs the Nix package manager and daemon, and then installs home-manager.
```bash
sh <(curl -L https://nixos.org/nix/install) --daemon
```
Then open a new shell and run the following command to install home-manager:
```bash
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
```
1. We need to get git and zsh on the machine. Add the following to your
`~/.config/home-manager/home.nix` file:
```nix
{ pkgs, ... }:
{
home.packages = [
# Add these 2 lines in the right place
pkgs.zsh
pkgs.git
];
}
```
1. Run the following command to install the git packages specified above:
```bash
home-manager switch
```
1. Copy your ssh key into `/home/<username>/.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`:
```bash
ssh-add ~/.ssh/id_ed25519
```
1. Run the following command to clone the latest version of the umbrella git repo:
```bash
# You can customise this with your favourite place to put git repos
SILVERCAT_GIT_CHECKOUTS_DIR=~/code/gh/bambooengineering
mkdir -p $SILVERCAT_GIT_CHECKOUTS_DIR
git clone [email protected]:bambooengineering/umbrella.git $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella
# Then link it to a known location
ln -s $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella ~/.umbrella
```
1. Add this to the top of your `~/.config/home-manager/home.nix` file:
```nix
imports = [
/home/<username>/.umbrella/bambrew/assets/nix/silvercat.nix
];
```
1. Run the following command to install the silvercat `home-manager` packages and system utilities.
Note, this is idempotent and should be quick once completed a 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
45 changes: 45 additions & 0 deletions run_bamstrap_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -e

if [ -z "$USER" ]; then
echo "Aborting! No USER environment variable set"
exit 3;
fi

if [ "$(id -u)" = 0 ]; then
echo "Aborting! Must not be run as root"
exit 4
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
# TODO: Need new shell here?
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 '<home-manager>' -A install
home-manager switch
# TODO: Need new shell here?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new shell required here, only after installing nix proper is one required 👍

fi

if [ ! -d "~/.umbrella" ]; then
"${SILVERCAT_GIT_CHECKOUTS_DIR:=$HOME/code/gh/bambooengineering}"
echo "Cloning umbrella into $SILVERCAT_GIT_CHECKOUTS_DIR... (change SILVERCAT_GIT_CHECKOUTS_DIR ENV to put it somewhere else)"
mkdir -p "$SILVERCAT_GIT_CHECKOUTS_DIR"
nix shell -p git -c "git clone [email protected]:bambooengineering/umbrella.git $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella"
ln -s "$SILVERCAT_GIT_CHECKOUTS_DIR/umbrella" ~/.umbrella
fi

# TODO: allow setting umbrella checkout branch if doing work on it etc..