ghcup-talk/GHCup.md
2024-05-19 21:28:41 +08:00

3.5 KiB

% GHCup % Julian Ospald % June 07, 2024

GHCup

Intro

Haskell Survey 2022

Intro (pt. 2)

haskell.org:

What is GHCup (simplified)?

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/

How it started

::: incremental

  • 🤹 small team at work on different platforms
  • 🧑‍💻 SHELL + POSIX
  • 🦾 first version was 165 LOC
  • 🙏 only installer at that time was stack

:::

Goals

::: incremental

  • ☮️ unification
  • unix principles
    • 🛠️ do one thing and do it well
    • ⚗️ pipes, compose stdout and stdin
  • 🎁 good re-distribution
  • 🛣️ user experience (get out of the way)

:::

What is GHCup really?

::: incremental

  • {#id .class width=32 height=32px} installer
  • {#id .class width=32 height=32px} distribution channel
  • {#id .class width=32 height=32px} feedback channel
  • {#id .class width=32 height=32px} testing/QA gateway
  • {#id .class width=32 height=32px} provider of sane defaults (e.g. "recommended" GHC version)
  • {#id .class width=32 height=32px} glue for holistic toolchain experience
    • stack integration
    • VSCode integration
    • cabal-install integration
  • {#id .class width=32 height=32px} CI provisioning (e.g. github actions)

:::

Upstream

Supported tools/dependencies:

::: incremental

  • GHC
  • Cabal
  • HLS
  • Stack

:::

Downstream

Users:

::: incremental

  • {#id .class height=32px} Haskell developers
    • beginners / advanced
    • student courses
    • companies
  • {#id .class width=32 height=32px} end users (e.g.compiling pandoc from source)
  • {#id .class width=32 height=32px} GitHub CI
    • GitHub images
    • Haskell repos
  • 🪞 mirrors
  • 🧰 tools

:::

How does it work?

Components:

::: incremental

  • {#id .class height=32px} cli interface
  • {#id .class height=32px} file layout / installation destination
  • {#id .class height=32px} bindist selection
  • 🧱 tui interface

:::

Basic CLI

::: incremental

  • show all available tools / versions
    ghcup list
    
  • install a tool
    ghcup install ghc latest
    
  • make a tool version the default
    ghcup set ghc latest
    
  • remove a tool version
    ghcup rm ghc 9.10.1
    

:::

Where does it install?

::: incremental

  • root dir

    $ ls ~/.ghcup
    bin  cache  config.yaml  db  env  ghc  hls  logs  share  tmp  trash
    
  • GHC and HLS are installed into sub-directories

    $ ls ~/.ghcup/ghc
    8.10.7	9.0.2	9.2.8
    
  • bin directory is mostly symbolic links

    $ ls ~/.ghcup/bin
    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
    

:::

Bindist selection