#+TITLE: Windows Subsystem for Linux Setup #+AUTHOR: James Blair #+EMAIL: mail@jamesblair.net #+DATE: 1st September 2019 * Setup home folder structure This section sets up my preferred set of initial folders inside my home directory. #+NAME: Setup home folder strucuture #+BEGIN_SRC shell cd ~/ mkdir Documents mkdir Downloads #+END_SRC * Update and install packages To get started we ensure the package manager is up to date. #+NAME: Update system packages #+BEGIN_SRC shell sudo apt-get update && sudo apt-get upgrade #+END_SRC #+RESULTS: Update system packages Next we install a series of standard packages that form part of our workflow or are dependencies for other tools in our environment. #+NAME: Install standard packages #+BEGIN_SRC shell sudo apt-get install -y git curl wget locales xclip tmux net-tools less \ software-properties-common htop wget apt-transport-https ca-certificates mutt #+END_SRC We use [[https://pandoc.org/][pandoc]] for documentation export from spacemacs. #+NAME: Install pandoc #+BEGIN_SRC shell curl -L -O https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb sudo dpkg -i /tmp/pandoc-2.7.3-1-amd64.deb #+END_SRC For additional package management we use node. The code below installs node ~12~. #+NAME: Install node #+BEGIN_SRC shell sudo curl -sL https://deb.nodesource.com/setup_12.x | sudo bash - sudo apt-get install -y nodejs #+END_SRC For managing secrets we use [[https://bitwarden.com/][bitwarden]] which provides a great [[https://github.com/bitwarden/cli][cli utility]]. #+NAME: Install bitwarden and login #+BEGIN_SRC shell export account=[BITWARDEN_ACCOUNT] sudo npm install -g @bitwarden/cli bw login $account #+END_SRC For working with google cloud platform we use the [[https://cloud.google.com/sdk/][GCP SDK]], which provides our cli tools. #+NAME: Install google cloud sdk #+BEGIN_SRC shell # Add the Cloud SDK distribution URI as a package source: echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list # Import the Google Cloud public key: curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - # Update and install the Cloud SDK: sudo apt-get update && sudo apt-get install google-cloud-sdk #+END_SRC For cloud infrastructure deployments we use [[https://www.terraform.io/][terraforms]]. #+NAME: Install hashicorp terraforms #+BEGIN_SRC shell # Download the binary wget 'https://releases.hashicorp.com/terraform/0.12.9/terraform_0.12.9_linux_amd64.zip' # Unzip it unzip *.zip # Move the binary to path sudo mv terraform /usr/bin/ # Clean up rm *amd64.zip #+END_SRC #+RESULTS: | Archive: | terraform_0.12.9_linux_amd64.zip | | inflating: | terraform | For ad-hoc system administration we use ansible #+NAME: Install ansible #+BEGIN_SRC shell sudo yum install -y ansible #+END_SRC * Install spacemacs A key component in our environment is spacemacs. The section below will setup version ~27.0.50~ of emacs and then spacemacs on top. #+NAME: Clone the emacs repository #+BEGIN_SRC tmate git clone -b stable --depth=1 https://github.com/ii/emacs #+END_SRC #+NAME: Install dependencies #+BEGIN_SRC tmate sudo apt-get install autoconf make gcc texinfo libgtk-3-dev libxpm-dev libjpeg-dev libgif-dev libtiff5-dev libgnutls28-dev libncurses5-dev #+END_SRC #+NAME: Compile and install emacs #+BEGIN_SRC tmate cd /emacs/ ./autogen.sh ./configure.sh make sudo make install #+END_SRC After compiling and installing emacs we should verify that version ~27.0.50~ is installed. #+BEGIN_SRC tmate emacs --version #+END_SRC * Setup a local emacs pacakge mirror To save time we will setup a local mirror for all the LISP files that we need as part of spacemacs. Depending on your machine and internet connection it may take some time to download, configure and compile. #+NAME: Setup local emacs elpa mirror #+BEGIN_SRC tmate sudo git clone --depth 1 -b stable https:/github.com/ii/elpa-mirror /usr/local/elpa-mirror #+END_SRC Setup spacemacs within our home folder. #+BEGIN_SRC tmate git clone --depth 1 -b stable --recurse-submodules https://github.com/ii/spacemacs.git ~/.emacs.d ln -sf ~/.emacs.d/private/local/dot-spacemacs/.spacemacs ~/.spacemacs emacs --batch -l ~/.emacs.d/init.el #+END_SRC * Setup mutt email client For reading email we ideally use a cli based client for fast searching and lightweight mail reading. The [[https://gitlab.com/muttmua/mutt/][mutt]] mail client fills these roles well for imap mailboxes. The first step to setup mutt is to ensure it is installed. #+NAME: Install mutt #+BEGIN_SRC shell sudo apt-get install mutt #+END_SRC After installing mutt we then need to create configuration directories and files. #+NAME: Create mutt config files #+BEGIN_SRC shell mkdir -p ~/.mutt/cache/headers mkdir ~/.mutt/cache/bodies touch ~/.mutt/certificates touch ~/.muttrc #+END_SRC One configuration folders and files exist we just need to populate our user mutt configuration file with a configuration for our particular mail provider. The example below utilises the ~bitwarden~ cli utility for secrets to ensure these are securely gathered at runtime and not stored in the file. #+NAME: Set mutt configuration #+BEGIN_SRC shell cat > ~/.muttrc << EOF set ssl_starttls=yes set ssl_force_tls=yes set imap_user=`bw get username hosted` set imap_pass=`bw get password hosted` set from=`bw get username hosted` set realname='James Blair' set folder=imaps://mail.jamesblair.net set header_cache="~/.mutt/cache/headers" set message_cachedir="~/.mutt/cache/bodies" set certificate_file="~/.mutt/certificates" set smtp_url="smtp://`bw get username hosted`@mail.jamesblair.net:587/" set smtp_pass=`bw get password hosted` set move=no set imap_keepalive=900 set postponed="=Drafts" set record="=Sent" set imap_passive=no set spoolfile=imaps://mail.jamesblair.net/INBOX EOF #+END_SRC * Setup environment dotfiles Within wsl we can use .dotfiles to further customise our environment. The script below restores my versions of key dotfiles automatically. #+NAME: Clone and restore the dotfiles #+BEGIN_SRC tmate git clone ssh://git@gitlab.jamma.life:2224/jmhbnz/tooling.git cd /tooling/ mv * ~/ #+END_SRC