Skip to content

Instantly share code, notes, and snippets.

@lukexi
Last active November 26, 2017 09:24
Show Gist options
  • Save lukexi/e634067f1d7e3a629988 to your computer and use it in GitHub Desktop.
Save lukexi/e634067f1d7e3a629988 to your computer and use it in GitHub Desktop.
Windows 10 Haskell Devbox Setup

Essentials

MSYS2

Install https://msys2.github.io/

pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime

Quit MSYS2 and relaunch it.

pacman -Su
pacman -S git

I turn off Git's conversion to CRLF, as we can work with LF just fine in MSYS2 & Sublime Text

git config --global core.autocrlf false

Install some helpful packages:

# Basic toolchain
pacman --needed -S base-devel mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain
# 7zip
pacman -S p7zip
# SDL
pacman -S mingw64/mingw-w64-x86_64-SDL2 mingw-w64-x86_64-pkg-config
# Freetype
pacman -S mingw64/mingw-w64-x86_64-freetype mingw64/mingw-w64-x86_64-glew

# FYI, to list all packages:
pacman -Ss | grep name

Cmder

Download cmder-mini from http://cmder.net/

Run Windows Powershell as Administator and run:

Set-ExecutionPolicy RemoteSigned

Create cmder_mingw64.bat in c:\msys64:

@echo off
cd /d c:\msys64

set MSYSTEM=MINGW64
call .\usr\bin\sh --login -i

In cmder settings>Tasks (under Startup) add a task named msys2 with the command:

-new_console:d:C:\msys64\home\YOUR_USERNAME "c:\msys64\cmder_mingw64.bat"
  • Under Startup: Check "Specify named task", {MSYS2}

  • Under Startup>Tasks: Check "Default task for new console"

  • Under Keys & Macro: add a hotkey for Ctrl-T to open {MSYS2}

To use ssh-agent, copy and paste from https://help.github.com/articles/working-with-ssh-key-passphrases/#auto-launching-ssh-agent-on-msysgit to ~/.profile

For git prompt niceties, download the git prompt script

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh

and add to ~/.profile:


BLACK="$(tput setaf 0 2>/dev/null || echo '\e[0;30m')"
RED="$(tput setaf 1 2>/dev/null || echo '\e[0;31m')"
GREEN="$(tput setaf 2 2>/dev/null || echo '\e[0;32m')" 
YELLOW="$(tput setaf 3 2>/dev/null || echo '\e[0;33m')"
BLUE="$(tput setaf 4 2>/dev/null || echo '\e[0;34m')"
PURPLE="$(tput setaf 5 2>/dev/null || echo '\e[0;35m')"
CYAN="$(tput setaf 6 2>/dev/null || echo '\e[0;36m')"
WHITE="$(tput setaf 7 2>/dev/null || echo '\e[0;37m')"

# Set up git prompt
source ~/.git-prompt.sh
PS1="\[$BLUE\]\u\[$YELLOW\]\[$YELLOW\]\w\[\033[m\]\[$PURPLE\]\$(__git_ps1)\[$WHITE\]\$ "

To allow Ctrl-LeftArrow and Ctrl-RightArrow navigation-by-word, add to ~/.inputrc

"\e[1;5C": forward-word   # ctrl + right
"\e[1;5D": backward-word  # ctrl + left

To allow selection with Shift-LeftArrow and Shift-RightArrow: Settings>Keys & Macro>Mark/Copy>Start selection with Shift+Arrow

To allow clicking to set the cursor: Settings>Keys & Macro>Mouse>Change prompt text cursor position with Left Click

Sublime Text

In Preferences > Settings - User, add:

"default_line_ending": "unix",
"hot_exit": false,
"remember_open_files":false,

these keep Sublime from trying to reopen old windows (buggy on Windows), and switches to LF endings

*Use View->Line Endings to convert files from CRLF to LF

(We don't want to use CRLF ever, as it complicates git, breaks Pd, and Sublime handles LF just fine in Windows)

Disable changing text size with control-scrollwheel http://superuser.com/questions/472468/in-sublime-text-how-do-you-disable-increase-decrease-font-size-with-ctrl-and-mo

GHC

Download GHC 8.0.2 (built by me, resolves a linker bug) https://github.com/lukexi/ghc/releases/download/8.0.1.1/ghc-8.0.1-x86_64-unknown-mingw32.tar.xz

tar xvf and copy to /usr/local/ghc

Add GHC and Sublime Text to Windows' PATH by right-clicking the Start menu and editing System > Advanced > Environment Variables > Path:

C:\msys64\usr\local\ghc\bin;%APPDATA%\local\bin;C:\Program Files\Sublime Text 3;

Stack

Make sure to use 64bit stack so we get 64bit GHC too https://www.stackage.org/stack/windows-x86_64-installer

Make sure stack uses the system GHC, and fix garbled stack output in Cmder: In %APPDATA%/stack/config.yaml

system-ghc: true
modify-code-page: false
skip-msys: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment