Last active
March 22, 2025 17:18
-
-
Save roustem/2702553a5baa21bd3abd1becf951445b to your computer and use it in GitHub Desktop.
Revisions
-
roustem renamed this gist
May 9, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
roustem created this gist
Jan 13, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,207 @@ # Setting up Windows 10 and WSL This document describes how to set up Windows 10 for cross-platform development (Go, NodeJS, etc) with Windows Subsystem for Linux (WSL). ## Resources Most of the information here is collected from * [http://wslcorsair.blogspot.com/](http://wslcorsair.blogspot.com/) * [https://brianketelsen.com/](https://brianketelsen.com/) ## WSL Setup 1. Download Brave beta and Firefox browsers, make either default. 2. Install 1Password for Windows, sign into personal and company accounts. 3. Add 1Password X extension in Brave and Firefox 4. Enable WSL and install latest version of Ubuntu from Microsoft Store 5. Create C:\home directory, move user's home folder there and update `/etc/passwd` with the new location ``` # in /etc/wsl.conf # Enable extra metadata options by default [automount] enabled = true options = "metadata,umask=22,fmask=11" mountFsTab = true ``` ### Default User Ubuntu will create a default user on the initial run. It can also be done manually: 1. Create new user in Ubuntu: `useradd -Um roustem` 2. Make sure that user is added to `sudoers` 3. Change default user (using PowerShell Admin): ``` ubuntu config --default-user roustem sc stop LxssManager sc start LxssManager ``` ## Install Ubuntu Apps ``` sudo apt update sudo apt upgrade sudo apt remove gnupg gpg sudo apt install gnupg2 fish tree graphviz build-essential unzip ``` ### Go ``` export GO_VERSION=1.11.4 curl -O "https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz" sudo mv /usr/local/go /usr/local/go.bak.$GO_VERSION # if installing new version sudo tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz ``` ### NodeJS ``` curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt -get install -y nodejs ``` ### Yarn ``` curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update sudo apt-get install yarn ``` ### GPG and Git ``` # Export key to `key.asc` file and then import gpg --import key.asc # or add --pinentry-mode if there is ap problem with entering the password gpg --import --pinentry-mode loopback key.asc git config --global commit.gpgsign true git config --global user.signingkey E25C1E01F3A98447 git config --global gpg.program /usr/bin/gpg git config --global user.email roustem@1password.com git config --global user.name Roustem git config --global url."git@gitlab.1password.io:".insteadOf "https://gitlab.1password.io/" git config --global url."git@gitlab.com:".insteadOf "[https://gitlab.com](https://gitlab.com)" ``` Debugging gpg signing: ``` echo “Test” | gpg --clear-sign ``` ### Google Cloud SDK https://cloud.google.com/sdk/docs/downloads-apt-get ``` sudo apt install kubectl gcloud init gcloud container clusters get-credentials cluster-dev ``` ## Install Windows Apps 1. Visual Studio Code 3. Git 4. Go 5. WSLtty 6. Gpg4win 7. Ditto ### Configure git After installing Go, press `Win-S`, type `PATH` and change the `GOPATH` to `C:\home\roustem\go`. This will make sure that GOPATH is shared with WSL and Go can pickup all libraries and vendored code. ``` git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe" git config --global commit.gpgsign true git config --global user.signingkey E25C1E01F3A98447 git config --global user.email roustem@1password.com git config --global user.name Roustem ``` ### Solving Git interoperability with WSL ``` git config --global core.filemode false git config --global core.autocrlf input ``` Also, make sure that local `.git/config` file has correct settings as well. Note: you might have to do this without `--global` in the repo as well. ### MinGW (optional) Install MinGW to get access to make and other command line tools. Update PATH to Include ``` C:\MinGW\bin C:\MinGW\msys\1.0\bin ``` ## Improving WSL Performance Based on [Speeding up WSL I/O ...](https://medium.com/@leandrw/speeding-up-wsl-i-o-up-than-5x-fast-saving-a-lot-of-battery-life-cpu-usage-c3537dd03c74), turn off Windows Defender protection for some folders and processes: Exclude folder: `%USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc` Exclude processes: - git - node - npm - dpkg - go ## Securing Docker [WSL Interoperability with Docker](https://blogs.msdn.microsoft.com/commandline/2017/12/08/cross-post-wsl-interoperability-with-docker/) ``` go get -d github.com/jstarks/npiperelay // on Windows: go install github.com/jstarks/npiperelay // in WSL: sudo apt install socat sudo apt install docker.io touch ~/docker-relay chmod +x ~/docker-relay vim ~/docker-relay // contents of ~/docker-relay #!/bin/sh exec socat UNIX-LISTEN:/var/run/docker.sock,fork,group=docker,umask=007 EXEC:"npiperelay.exe -ep -s //./pipe/docker_engine",nofork // end ^^^ sudo adduser roustem docker ``` ## Configure Ditto Set keyboard shortcut to `Alt-V` Exclude `1Password` binary Add image clipboard type ## Miscellaneous Windows Tips Keyboard Shortcuts: - `Cmd-Shift-S` – take a screenshot and save it to clipboard - `Win-.` – show emoji panel (see Advanced Keyboard settings to control if emoji panel closes automatically) Configure system and user path: - `Win-S`, type "PATH" Configure taskbar: - `Cmd-S`, type "system icons" - <!--stackedit_data: eyJoaXN0b3J5IjpbLTE4MDMwNDIzM119 -->