ghcup-talk/GHCup.md

421 lines
12 KiB
Markdown
Raw Normal View History

2024-05-18 17:05:23 +00:00
% GHCup
% Julian Ospald
% June 07, 2024
2024-05-30 13:13:08 +00:00
# Introduction
2024-05-18 17:05:23 +00:00
2024-05-24 15:31:24 +00:00
## What is GHCup?
2024-05-18 17:05:23 +00:00
2024-05-24 15:31:24 +00:00
![](what.jpg)
2024-05-18 17:05:23 +00:00
2024-05-24 15:31:24 +00:00
## State of 2019
2024-05-18 17:05:23 +00:00
2024-05-24 15:31:24 +00:00
::: incremental
2024-05-19 11:59:02 +00:00
2024-05-24 15:31:24 +00:00
* stack is the only "Haskell Installer"
* no unified alternative for cabal users
* distro packages, nix, manual installs, ...
* 🤮
2024-05-18 17:05:23 +00:00
2024-05-24 15:31:24 +00:00
:::
2024-05-18 17:05:23 +00:00
## How it started
2024-05-19 11:59:02 +00:00
::: incremental
2024-05-24 15:31:24 +00:00
* 🤹 small team at work (Capital Match), using different platforms
- originally used stack
- cabal distro packages constantly out of date
2024-05-18 17:05:23 +00:00
* 🦾 first version was 165 LOC
2024-05-24 15:31:24 +00:00
- Posix shell
* ![](linux.png){#id .class height=32px} only supported linux and mac
* ![](rust.png){#id .class height=32px} inspired by **rustup**
2024-05-18 17:05:23 +00:00
2024-05-19 11:59:02 +00:00
:::
2024-05-24 15:31:24 +00:00
## GHCup today
2024-05-30 13:13:08 +00:00
[Haskell Survey 2022](https://taylor.fausak.me/2022/11/18/haskell-survey-results/#s2q1):
![](survey.png)
. . .
2024-05-24 15:31:24 +00:00
- over **17k** LOC Haskell
- supports all platforms: Linux, Windows, macOS, FreeBSD
## GHCup and haskell.org
2024-05-30 13:13:08 +00:00
The default installer:
2024-05-24 15:31:24 +00:00
2024-05-30 13:13:08 +00:00
![](downloads.png)
2024-05-24 15:31:24 +00:00
2024-05-30 13:13:08 +00:00
. . .
* provides infrastructure (home page, downloads)
2024-05-24 15:31:24 +00:00
## GHCup and the Haskell Foundation
::: incremental
* affiliation: [https://haskell.foundation/affiliates/](https://haskell.foundation/affiliates/)
* pays for CI
* pays consultants to assist the project
:::
2024-05-30 13:13:08 +00:00
# Philosophy
2024-05-24 15:31:24 +00:00
## What is a good installer?
::: incremental
* it installs (just that)
- everywhere
* intuitive interface
- `ghcup install ghc`
* good documentation
- but you shouldn't have to read it
* get out of the way
- has no self-fulfilling purpose
:::
## Goals and principles
2024-05-18 17:05:23 +00:00
2024-05-19 11:59:02 +00:00
::: incremental
2024-05-18 17:05:23 +00:00
- ☮️ unification
- unix principles
- 🛠️ do one thing and do it well
2024-05-24 15:31:24 +00:00
- ⚗️ pipes, compose stdout and stdin (re-usable)
2024-05-18 17:05:23 +00:00
- 🎁 good re-distribution
2024-05-24 15:31:24 +00:00
- 🛣️ user experience
2024-05-18 17:05:23 +00:00
2024-05-19 11:59:02 +00:00
:::
2024-05-24 15:31:24 +00:00
## What is GHCup (simplified)?
```sh
curl -s -L 'https://downloads.haskell.org/~ghc/9.6.5/ghc-9.6.5-x86_64-fedora33-linux.tar.xz' |
tar -xJ -C /tmp &&
cd /tmp/ghc-9.6.5-x86_64-unknown-linux/ &&
./configure --prefix="$HOME/.local" &&
make install &&
rm -rf /tmp/ghc-9.6.5-x86_64-unknown-linux/
```
2024-05-19 11:59:02 +00:00
## What is GHCup really?
2024-05-18 17:05:23 +00:00
* [https://hasufell.github.io/posts/2023-11-14-ghcup-is-not-an-installer.html](https://hasufell.github.io/posts/2023-11-14-ghcup-is-not-an-installer.html)
2024-05-19 11:59:02 +00:00
::: incremental
2024-05-18 17:05:23 +00:00
* ![](open-box.png){#id .class width=32 height=32px} installer
2024-05-24 15:31:24 +00:00
* ![](debian.png){#id .class width=32 height=32px} distribution channel
2024-05-18 17:05:23 +00:00
* ![](feedback.png){#id .class width=32 height=32px} feedback channel
2024-05-19 11:59:02 +00:00
* ![](qa.png){#id .class width=32 height=32px} testing/QA gateway
* ![](user.png){#id .class width=32 height=32px} provider of sane defaults (e.g. "recommended" GHC version)
* ![](chain-saw.png){#id .class width=32 height=32px} glue for holistic toolchain experience
2024-05-24 15:31:24 +00:00
- VSCode, stack, cabal-install integration
2024-05-19 11:59:02 +00:00
* ![](ghaction.png){#id .class width=32 height=32px} CI provisioning (e.g. github actions)
:::
2024-06-01 13:31:00 +00:00
# Relationships
2024-05-30 13:13:08 +00:00
## Upstream (dependencies)
2024-05-19 11:59:02 +00:00
2024-06-01 13:31:00 +00:00
- supported tools
- GHC
- Cabal
- HLS
- Stack
2024-05-19 11:59:02 +00:00
2024-06-01 13:31:00 +00:00
. . .
2024-05-19 11:59:02 +00:00
2024-06-01 13:31:00 +00:00
- decisions that affect us
- release frequency
- upstream CI
- platform support
- binary distributions (the `.tar.gz`/`.zip`)
2024-05-19 11:59:02 +00:00
2024-05-30 13:13:08 +00:00
## Downstream (dependents)
2024-05-19 11:59:02 +00:00
- ![](haskell_logo.png){#id .class height=32px} Haskell developers
2024-05-24 15:31:24 +00:00
- beginners, advanced, students, companies
- ![](person.png){#id .class width=32 height=32px} end users (e.g. compiling pandoc from source)
2024-05-19 11:59:02 +00:00
- ![](ghaction.png){#id .class width=32 height=32px} GitHub CI
2024-05-24 15:31:24 +00:00
- GitHub images, Haskell repos
2024-05-19 11:59:02 +00:00
- 🪞 mirrors
- [sjtug](https://mirror.sjtu.edu.cn/docs/ghcup)
- 🧰 tools
2024-05-24 15:31:24 +00:00
- [vscode-haskell](https://github.com/haskell/vscode-haskell), [Haskell playground](https://play.haskell.org/), [nvim-lsp-installer](https://github.com/williamboman/nvim-lsp-installer)
2024-05-19 11:59:02 +00:00
2024-06-01 13:31:00 +00:00
# The installer in detail
2024-05-30 13:13:08 +00:00
2024-05-19 11:59:02 +00:00
## How does it work?
2024-05-24 15:31:24 +00:00
* **Architectural components**
- ![](sh-file.png){#id .class height=32px} bootstrap scripts
- ![](exe-file.png){#id .class height=32px} ghcup binary (compiled)
2024-05-30 13:13:08 +00:00
- ![](config-file.png){#id .class height=32px} ghcup-metadata
2024-06-01 13:31:00 +00:00
. . .
2024-05-24 15:31:24 +00:00
* **Logical components**
- ![](terminal.png){#id .class height=32px} cli interface
- ![](file.png){#id .class height=32px} file layout / installation destination
- ![](tar.png){#id .class height=32px} bindist selection
- ![](brick-final-clearbg.png){#id .class height=32px} tui interface
2024-05-30 13:13:08 +00:00
- ![](config.svg){#id .class height=32px} configuration
2024-05-19 11:59:02 +00:00
2024-05-25 11:34:49 +00:00
## Basic CLI (context)
* **Architectural components**
- [ ] ![](sh-file.png){#id .class height=32px} bootstrap scripts
- [x] ![](exe-file.png){#id .class height=32px} ghcup binary (compiled)
2024-05-30 13:13:08 +00:00
- [ ] ![](config-file.png){#id .class height=32px} ghcup-metadata
2024-05-25 11:34:49 +00:00
* **Logical components**
- [x] ![](terminal.png){#id .class height=32px} cli interface
- [ ] ![](file.png){#id .class height=32px} file layout / installation destination
- [ ] ![](tar.png){#id .class height=32px} bindist selection
- [ ] ![](brick-final-clearbg.png){#id .class height=32px} tui interface
2024-05-30 13:13:08 +00:00
- [ ] ![](config.svg){#id .class height=32px} configuration
2024-05-25 11:34:49 +00:00
2024-05-19 11:59:02 +00:00
## Basic CLI
::: incremental
* show all available tools / versions
```sh
ghcup list
```
* install a tool
```sh
ghcup install ghc latest
```
* make a tool version the default
```sh
ghcup set ghc latest
```
* remove a tool version
```sh
ghcup rm ghc 9.10.1
```
:::
2024-05-25 11:34:49 +00:00
## File layout (context)
* **Architectural components**
- [ ] ![](sh-file.png){#id .class height=32px} bootstrap scripts
- [x] ![](exe-file.png){#id .class height=32px} ghcup binary (compiled)
2024-05-30 13:13:08 +00:00
- [ ] ![](config-file.png){#id .class height=32px} ghcup-metadata
2024-05-25 11:34:49 +00:00
* **Logical components**
- [ ] ![](terminal.png){#id .class height=32px} cli interface
- [x] ![](file.png){#id .class height=32px} file layout / installation destination
- [ ] ![](tar.png){#id .class height=32px} bindist selection
- [ ] ![](brick-final-clearbg.png){#id .class height=32px} tui interface
2024-05-30 13:13:08 +00:00
- [ ] ![](config.svg){#id .class height=32px} configuration
2024-05-25 11:34:49 +00:00
## File layout
2024-05-19 11:59:02 +00:00
::: incremental
* root dir
```sh
$ ls ~/.ghcup
2024-05-24 15:31:24 +00:00
📁bin 📁ghc 📁hls
📁cache 📁db 📁logs 📁tmp 🗑trash 📄config.yaml 📄env
2024-05-19 11:59:02 +00:00
```
* GHC and HLS are installed into sub-directories
```sh
$ ls ~/.ghcup/ghc
2024-05-24 15:31:24 +00:00
📁8.10.7 📁9.0.2 📁9.2.8
2024-05-19 11:59:02 +00:00
```
2024-05-24 15:31:24 +00:00
* bin directory is mostly symbolic links (compare with [update-alternatives](https://man7.org/linux/man-pages/man1/update-alternatives.1.html))
2024-05-19 11:59:02 +00:00
```sh
$ ls ~/.ghcup/bin
2024-05-24 15:31:24 +00:00
📄ghcup
🔗cabal 📄cabal-3.10.3.0
🔗ghc 🔗ghc-8.10 🔗ghc-8.10.7 🔗ghc-9.0 🔗ghc-9.0.2 🔗ghc-9.2 🔗ghc-9.2.8
2024-05-19 11:59:02 +00:00
```
:::
2024-05-25 11:34:49 +00:00
## Bindist selection (context)
* **Architectural components**
- [ ] ![](sh-file.png){#id .class height=32px} bootstrap scripts
- [x] ![](exe-file.png){#id .class height=32px} ghcup binary (compiled)
2024-05-30 13:13:08 +00:00
- [x] ![](config-file.png){#id .class height=32px} ghcup-metadata
2024-05-25 11:34:49 +00:00
* **Logical components**
- [ ] ![](terminal.png){#id .class height=32px} cli interface
- [ ] ![](file.png){#id .class height=32px} file layout / installation destination
- [x] ![](tar.png){#id .class height=32px} bindist selection
- [ ] ![](brick-final-clearbg.png){#id .class height=32px} tui interface
2024-05-30 13:13:08 +00:00
- [ ] ![](config.svg){#id .class height=32px} configuration
2024-05-25 11:34:49 +00:00
## Bindist selection (sysinfo)
**Gather system information:**
::: incremental
* module `GHCup.Platform`
* `System.Info.arch` and `System.Info.os` (compile-time strings)
* distro detection mostly via `/etc/os-release`
- specified by [freedesktop.org](https://www.freedesktop.org/software/systemd/man/latest/os-release.html)
- using [os-release](https://hackage.haskell.org/package/os-release) package for parsing
:::
## Bindist selection (mapping)
**Map binaries to systems:**
::: incremental
- binary compatibility (platform, distro, distro version)
- finite set of binaries
- statically linked GHC?
- static mapping in [ghcup-metadata YAML files](https://github.com/haskell/ghcup-metadata/blob/develop/ghcup-0.0.8.yaml)
- Tool -> Version -> Architecture -> Platform/Distro -> binary URL
- mapping based on binary compatibility
- [https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms/linux](https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms/linux)
- alternative dynamic logic (utilizing `ldconfig -p` output)
- for stack compatibility
- updated on every release
- "channels"
:::
## Installation flow
![](install-flow.svg){#id .class height=500px}
## TUI interface (context)
* **Architectural components**
- [ ] ![](sh-file.png){#id .class height=32px} bootstrap scripts
- [x] ![](exe-file.png){#id .class height=32px} ghcup binary (compiled)
2024-05-30 13:13:08 +00:00
- [ ] ![](config-file.png){#id .class height=32px} ghcup-metadata
2024-05-25 11:34:49 +00:00
* **Logical components**
- [ ] ![](terminal.png){#id .class height=32px} cli interface
- [ ] ![](file.png){#id .class height=32px} file layout / installation destination
- [ ] ![](tar.png){#id .class height=32px} bindist selection
- [x] ![](brick-final-clearbg.png){#id .class height=32px} tui interface
2024-05-30 13:13:08 +00:00
- [ ] ![](config.svg){#id .class height=32px} configuration
2024-05-19 11:59:02 +00:00
2024-05-25 11:34:49 +00:00
## TUI interface
2024-05-18 17:05:23 +00:00
2024-05-30 13:13:08 +00:00
![](matrix.png){#id .class height=550px}
## Configuration (context)
* **Architectural components**
- [X] ![](sh-file.png){#id .class height=32px} bootstrap scripts
- [x] ![](exe-file.png){#id .class height=32px} ghcup binary (compiled)
- [x] ![](config-file.png){#id .class height=32px} ghcup-metadata
* **Logical components**
- [ ] ![](terminal.png){#id .class height=32px} cli interface
- [ ] ![](file.png){#id .class height=32px} file layout / installation destination
- [ ] ![](tar.png){#id .class height=32px} bindist selection
- [ ] ![](brick-final-clearbg.png){#id .class height=32px} tui interface
- [x] ![](config.svg){#id .class height=32px} configuration
## Configuration
::: incremental
* Types of configuration:
- environment variables
- cli switches / TUI options
- config file (`~/.ghcup/config.yaml`)
* e.g.
- env: `GHCUP_INSTALL_BASE_PREFIX` (default `$HOME`)
- cli: `ghcup install ghc -u <url> <version>`
- config: `url-source` (selecting and mixing "channels")
- file/http/https URI
- `GHCupURL`
- `StackSetupURL`
:::
## Phew
![](headache.png){#id .class height=550px}
2024-06-01 13:31:00 +00:00
# Distribution
## What is distribution?
* QA gate between "upstream" and "downstream"
* trust relationship (with upstream and downstream)
* release selection and defaults
* binary distribution
## What happens on e.g. a GHC release
- testing and inspection of bindists
- manual
- automated at [github.com/haskell/ghcup-metadata](https://github.com/haskell/ghcup-metadata/blob/develop/.github/workflows/bindists.yaml)
- fixing bindists
- building additional bindists (e.g. FreeBSD)
. . .
- forks at [github.com/stable-haskell](https://github.com/stable-haskell)
- builds cabal, stack and HLS binaries
- GHC TBD
## The "recommended" versions (defaults)
* community adoption (both industry and "open source")
* stack LTS
* HLS support
* known issues and regressions
* GHC HQs opinion and support window
* must be consistent across platforms
2024-05-30 13:13:08 +00:00
# Contributing
## How to contribute
2024-06-01 13:31:00 +00:00
::: incremental
2024-05-30 13:13:08 +00:00
2024-06-01 13:31:00 +00:00
- loose project structure (BDFL)
- discuss early
- repositories
- [github.com/haskell/ghcup-hs](https://github.com/haskell/ghcup-hs): documentation, bootstrap-scripts, ghcup exe
- [github.com/haskell/ghcup-metadata](https://github.com/haskell/ghcup-metadata): bindist mapping (YAML), bindist testing
- build with cabal/stack
- communication
- [#haskell-ghcup](https://kiwiirc.com/nextclient/irc.libera.chat/?nick=Guest%7C?##haskell-ghcup) on libera IRC
- [#ghcup:matrix.org](https://matrix.to/#/#ghcup:matrix.org) (bridged with IRC)
2024-06-01 14:07:00 +00:00
- [github issues](https://github.com/haskell/ghcup-hs/issues)
2024-06-01 13:31:00 +00:00
- [haskell discourse](https://discourse.haskell.org/) (interacting with the community)
2024-05-30 13:13:08 +00:00
2024-06-01 13:31:00 +00:00
:::
2024-05-30 13:13:08 +00:00
2024-06-01 14:07:00 +00:00
## Getting started
Head over to [https://github.com/haskell/ghcup-hs/issues/1074](https://github.com/haskell/ghcup-hs/issues/1074) (`zurihac` labeled issue).
2024-05-30 13:13:08 +00:00
## Advanced topics
- bootstrap scripts
- windows and MSYS2
- security
- HLS/GHC interaction
- reproducibility
- stack integration
- bindist work (curation)
- isolated installs
- mirrors