Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.

Commit 0b57187

Browse files
committed
Add a bootstrap-haskell script, fixes #36
1 parent d46eb55 commit 0b57187

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ Similar in scope to [rustup](https://github.com/rust-lang-nursery/rustup.rs), [p
1919

2020
## Installation
2121

22+
### Simple bootstrap of ghcup, GHC and cabal-install
23+
24+
```sh
25+
# complete bootstrap
26+
curl https://raw.githubusercontent.com/haskell/ghcup/master/bootstrap-haskell -sSf | sh
27+
28+
# prepare your environment
29+
. "$HOME/.ghcup/env"
30+
echo '. $HOME/.ghcup/env' >> "$HOME/.bashrc" # or similar
31+
32+
# now create a project, such as:
33+
mkdir myproject && cd myproject
34+
cabal init -n --is-executable
35+
cabal v2-run
36+
```
37+
38+
### Manual install
39+
2240
Just place the `ghcup` shell script into your `PATH` anywhere.
2341

2442
E.g.:

bootstrap-haskell

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/sh
2+
3+
die() {
4+
(>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1")
5+
exit 2
6+
}
7+
8+
edo()
9+
{
10+
printf "\\033[0;35m%s\\033[0m\\n" "$*"
11+
"$@" || exit 2
12+
}
13+
14+
echo
15+
echo "Welcome to Haskell!"
16+
echo
17+
echo "This will download and install the Glasgow Haskell Compiler (GHC) for "
18+
echo "the Haskell programming language, and the Cabal build tool."
19+
echo
20+
echo "It will add the 'cabal', 'ghc', and 'ghcup' executables to bin directory "
21+
echo "located at: "
22+
echo
23+
echo " $HOME/.ghcup/bin"
24+
echo
25+
echo "and create the environment file $HOME/.ghcup/env"
26+
echo "which you should source in your ~/.bashrc or similar to get the required"
27+
echo "PATH components."
28+
echo
29+
30+
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
31+
echo "To proceed with the installation press enter, to cancel press ctrl-c."
32+
echo "Note that this script can be re-run at any given time."
33+
echo
34+
35+
# Wait for user input to continue.
36+
# shellcheck disable=SC2034
37+
read -r answer </dev/tty
38+
fi
39+
40+
edo mkdir -p "${HOME}"/.ghcup/bin
41+
42+
if command -V "ghcup" >/dev/null 2>&1 ; then
43+
if [ -z "${BOOTSTRAP_HASKELL_NO_UPGRADE}" ] ; then
44+
edo ghcup upgrade
45+
fi
46+
else
47+
edo curl https://raw.githubusercontent.com/haskell/ghcup/master/ghcup > "${HOME}"/.ghcup/bin/ghcup
48+
edo chmod +x "${HOME}"/.ghcup/bin/ghcup
49+
50+
cat <<-EOF > "${HOME}"/.ghcup/env || die "Failed to create env file"
51+
export PATH="\$HOME/.cabal/bin:\$HOME/.ghcup/bin:\$PATH"
52+
EOF
53+
# shellcheck disable=SC1090
54+
edo . "${HOME}"/.ghcup/env
55+
fi
56+
57+
edo ghcup install
58+
59+
edo ghcup set
60+
edo ghcup install-cabal
61+
62+
edo cabal new-update
63+
edo cabal new-install --symlink-bindir="$HOME/.cabal/bin" cabal-install
64+
65+
printf "\\033[0;35m%s\\033[0m\\n" ""
66+
printf "\\033[0;35m%s\\033[0m\\n" "Installation done!"
67+
printf "\\033[0;35m%s\\033[0m\\n" ""
68+
printf "\\033[0;35m%s\\033[0m\\n" "Don't forget to source $HOME/.ghcup/env in your ~/.bashrc or similar."
69+
printf "\\033[0;35m%s\\033[0m\\n" ""

0 commit comments

Comments
 (0)