You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.6 KiB

  1. #+title: Installing stack on ARM bit
  2. #+author: Annwan
  3. #+date: 2022:03:04
  4. #+options: h:1 num:nil toc:nil
  5. ** Why stack on ARM
  6. People might want to run Haskell applications on ARM devices like a
  7. Raspberry Pi. The Haskell compiler has supported the architecture
  8. through LLVM for a couple of year now, as well as the builtin dependency
  9. manager, Cabal. However the dependency management of Cabal is
  10. system-wide (or at least user wide) and, because all packages interact
  11. with each other, it can pose problems with compatibility.
  12. That is the problem that =stack= solves by allowing for reproducible,
  13. isolated environment for each project, and a lot of projects now use
  14. stack for their dependency and version management.
  15. However stack does not provide any build for arm systems, we thus need
  16. to install it another way
  17. ** Contents
  18. #+TOC
  19. ** First step, getting a compiler
  20. Whereas =stack= does not provide an ARM build, GHC does. so we first
  21. head to the [[https://www.haskell.org/ghc/][GHC download page]] and get the latest build. Usually the
  22. archive is for Debian, but should work for any GNU libc based
  23. distribution.
  24. #+begin_quote
  25. At time of writing stack doesn't handle GHC 9 properly yet so the used
  26. version is 8.10.7.
  27. #+end_quote
  28. This should leave you with an archive like
  29. =ghc-8.10.7-aarch64-deb10-linux.tar.xz= (Keep that archive around, we
  30. will need it for stack later on).
  31. We are now going to extract and setup a minimal Haskell environment
  32. #+begin_src shell
  33. tar xvf ghc-8.10.7-aarch64-deb10-linux.tar.xz
  34. cd ghc-8.10.7
  35. ./configure --prefix=$HOME/.cabal
  36. make install
  37. #+end_src
  38. Next grab the latest cabal binary for AArch64 from [[https://www.haskell.org/cabal/download.html][Cabal download page]]
  39. (usually tagged as for Debian but should work on any GNU Libc system).
  40. Put the contained executable in =$HOME/.cabal/bin=
  41. Finally put =$HOME/.cabal/bin= in your PATH.
  42. You now have a minimal Haskell installation in your path, we are now
  43. ready to move to the next step
  44. ** Install a stack bootstrap environment
  45. Now that we can compile some Haskell things, lets install a bootstrap
  46. stack installation. It is not the final one, because this one is tied to
  47. a cabal version instead of a stack snapshot
  48. To do that we simply tell cabal to install stack
  49. #+begin_src shell
  50. cabal install stack
  51. #+end_src
  52. This compilation will take a bunch of memory, and most likely a while, if
  53. on a system with limited RAM, you might want to unmout the tmpfs at
  54. =/tmp= and increase the swap size in order to have around 4GB free
  55. ** Register the compiler with stack
  56. Remember when I said to keep the GHC archive around because we will need
  57. it later, well that later is now. Move that archive to a folder where
  58. you'll most likely not accidentally delete it, here I'll use =~/ghc=
  59. Once the archive is stored in that folder, open your stack configuration
  60. (=~/.stack/config.yaml=) and add the following
  61. #+begin_src yaml
  62. setup-info:
  63. ghc:
  64. linux-aarch64-tinfo6:
  65. 8.10.7:
  66. url: "~/ghc/ghc-8.10.7-aarch64-deb10-linux.tar.xz"
  67. #+end_src
  68. ** Finaly, bootstrap stack with itself
  69. Now we need to reinstall stack with itself, to untie it from the
  70. temporary setup.
  71. #+begin_src shell
  72. stack setup
  73. stack install stack
  74. #+end_src
  75. Once again this will take a lot of both memory and time.
  76. ** Clean up
  77. You can now remove the =~/.cabal/bin= folder and add the =~/.local/bin=
  78. folder to the path, that is where stack will install binaries.
  79. You can also delete the =~/.cabal= as it is no longer needed
  80. Once this is done, you now have a fully functionnal stack setup.
  81. If in the future you need an additionnal compiler version you can add
  82. its archive to the compilers folder and register it with stack the same
  83. way as previously done.