From 119e7f016006f68e2b4062ec44c09130f0b08c6b Mon Sep 17 00:00:00 2001 From: Harry Lascelles Date: Wed, 14 May 2025 13:51:56 +0100 Subject: [PATCH 1/5] Add instructions for setup with home-manager and mise --- .gitignore | 1 + README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) 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..0385307 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,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 '' -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//.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 git@github.com: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//.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 From 47b4512497667034e35f67eeb63b8426a89bda86 Mon Sep 17 00:00:00 2001 From: Harry Lascelles Date: Fri, 16 May 2025 11:00:52 +0100 Subject: [PATCH 2/5] Install script --- run_bamstrap_linux | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 run_bamstrap_linux diff --git a/run_bamstrap_linux b/run_bamstrap_linux new file mode 100755 index 0000000..2605c4c --- /dev/null +++ b/run_bamstrap_linux @@ -0,0 +1,43 @@ +#!/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 '' -A install + home-manager switch + # TODO: Need new shell here? +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 git@github.com:bambooengineering/umbrella.git $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella" + ln -s "$SILVERCAT_GIT_CHECKOUTS_DIR/umbrella" ~/.umbrella +fi From 88bf51c97cce25349fa8f875868dd67fad5cab2a Mon Sep 17 00:00:00 2001 From: Harry Lascelles Date: Fri, 16 May 2025 11:01:19 +0100 Subject: [PATCH 3/5] Install script --- run_bamstrap_linux | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_bamstrap_linux b/run_bamstrap_linux index 2605c4c..79d604a 100755 --- a/run_bamstrap_linux +++ b/run_bamstrap_linux @@ -41,3 +41,5 @@ if [ ! -d "~/.umbrella" ]; then 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 + +# TODO: allow setting umbrella checkout branch if doing work on it etc.. From a87647e46fe1b0cff69db989f63feb49ad049a37 Mon Sep 17 00:00:00 2001 From: Mark Coyle Date: Tue, 20 May 2025 11:01:47 +0100 Subject: [PATCH 4/5] wip: Nix-shell & gh --- README.md | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 0385307..84001a1 100644 --- a/README.md +++ b/README.md @@ -29,50 +29,40 @@ in that repo. nix-channel --update nix-shell '' -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//.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: +2. We need to get git and zsh on the machine. Run: + `nix-shell -p zsh git gh` +3. Step three is optional you can either: + 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`: + ```bash + 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. + +4. 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 git@github.com:bambooengineering/umbrella.git $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella - # Then link it to a known location + gh repo clone bambooengineering/umbrella $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: +5. Add this to the top of your `~/.config/home-manager/home.nix` file: ```nix imports = [ /home//.umbrella/bambrew/assets/nix/silvercat.nix ]; ``` -1. Run the following command to install the silvercat `home-manager` packages and system utilities. +6. 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. ``` From c0a3afb9a1150bd3e943733e98a154dc25b7c37b Mon Sep 17 00:00:00 2001 From: Harry Lascelles Date: Thu, 22 May 2025 11:56:44 +0100 Subject: [PATCH 5/5] README updates --- README.md | 47 ++++++++++------------------------------------ run_bamstrap_linux | 34 +++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 84001a1..c2110e5 100644 --- a/README.md +++ b/README.md @@ -15,55 +15,28 @@ sh -c "$(curl -fsSL https://github.com/bambooengineering/bambrew/raw/master/run_ # 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 +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 '' -A install - ``` -2. We need to get git and zsh on the machine. Run: - `nix-shell -p zsh git gh` -3. Step three is optional you can either: - 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`: - ```bash - 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. +The script in this repo will achieve that. The steps are: -4. 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 - gh repo clone bambooengineering/umbrella $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella - # Then link it to a known location - ln -s $SILVERCAT_GIT_CHECKOUTS_DIR/umbrella ~/.umbrella - ``` -5. Add this to the top of your `~/.config/home-manager/home.nix` file: +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 ]; ``` -6. 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 +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 + ~/.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 index 79d604a..dc6b498 100755 --- a/run_bamstrap_linux +++ b/run_bamstrap_linux @@ -2,14 +2,21 @@ 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 [ "$(id -u)" = 0 ]; then - echo "Aborting! Must not be run as root" - exit 4 +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 @@ -22,7 +29,8 @@ fi if [ ! -d "nix" ]; then echo "Installing nix..." sh <(curl -L https://nixos.org/nix/install) --daemon - # TODO: Need new shell here? + echo "Done installing nix! Open a new shell then run this script again." + exit 1 fi if [ -x "$(command -v home-manager)" ]; then @@ -31,15 +39,25 @@ if [ -x "$(command -v home-manager)" ]; then nix-channel --update nix-shell '' -A install home-manager switch - # TODO: Need new shell here? + + 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 - "${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)" + 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 -# TODO: allow setting umbrella checkout branch if doing work on it etc.. +echo "Completed checkout. Now add the silvercat.nix to your home-manager config and "