Skip to content

Instantly share code, notes, and snippets.

@0xmohit
Last active June 30, 2016 11:39
Show Gist options
  • Save 0xmohit/af81bcee9f614fbf0ca5 to your computer and use it in GitHub Desktop.
Save 0xmohit/af81bcee9f614fbf0ca5 to your computer and use it in GitHub Desktop.
Installing GHC on Ubuntu
#!/bin/sh
GHC_VERSION=8.0.1
CABAL_VERSION=1.24.0.0
CABAL_INSTALL_VERSION=1.24.0.0
CABAL_INSTALL_DIR=/usr/local/cabal
# Installing ghc
cd /tmp
sudo apt-get -y install libgmp-dev
wget http://hackage.haskell.org/package/cabal-install-${CABAL_INSTALL_VERSION}/cabal-install-${CABAL_INSTALL_VERSION}.tar.gz
tar Jxvf ghc-${GHC_VERSION}-x86_64-unknown-linux-deb7.tar.xz
cd ghc-${GHC_VERSION}
./configure
sudo make install
# Installing Cabal
cd /tmp
wget http://hackage.haskell.org/package/Cabal-${CABAL_VERSION}/Cabal-${CABAL_VERSION}.tar.gz
tar zxvf Cabal-${CABAL_VERSION}.tar.gz
cd Cabal-${CABAL_VERSION}
ghc -threaded --make Setup
./Setup configure --enable-library-profiling
./Setup build
sudo ./Setup install
# Installing cabal-install
cd /tmp
wget http://hackage.haskell.org/package/cabal-install-${CABAL_INSTALL_VERSION}/cabal-install-${CABAL_INSTALL_VERSION}.tar.gz
tar zxvf cabal-install-${CABAL_INSTALL_VERSION}.tar.gz
sudo mkdir -p ${CABAL_INSTALL_DIR}
sudo CABAL_VERSION=${CABAL_VERSION} CABAL_INSTALL_VERSION=${CABAL_INSTALL_VERSION} sh -c 'cat <<EOF > /usr/local/cabal/config
-- This is the configuration file for the 'cabal' command line tool.
-- Cabal library version: ${CABAL_VERSION}
-- cabal-install version: ${CABAL_INSTALL_VERSION}
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: ${CABAL_INSTALL_DIR}/packages
world-file: ${CABAL_INSTALL_DIR}/world
extra-prog-path: ${CABAL_INSTALL_DIR}/bin
user-install: False
library-profiling: True
EOF'
cd cabal-install-${CABAL_INSTALL_VERSION}
sudo ./bootstrap.sh --global
sudo cabal --config-file=/usr/local/cabal/config update
# Optional: install packages from [Hackage](http://hackage.haskell.org/) globally
sudo cabal --config-file=/usr/local/cabal/config install lens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment