Skip to content

Commit

Permalink
Source HLS on Apple Silicon too, at long last
Browse files Browse the repository at this point in the history
  • Loading branch information
samhh committed Sep 13, 2023
1 parent a9ee8f2 commit d874b0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ The description is optional and ignored by intlc. It can be used documentatively

Check out `ARCHITECTURE.md`.

Currently building against GHC 9.2.4. A Nix flake is included with all necessary dependencies. Contributors on Apple silicon will need to source GHC and HLS externally, for example via ghcup.
Currently building against GHC 9.4.6. A Nix flake is included with all necessary dependencies.
48 changes: 7 additions & 41 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
# There are two major considerations when picking a version of GHC for this
# project.
#
# Firstly, we'd like the version we choose to have tooling available in Nix's
# binary cache, without contributors having to mess around with additional
# caches. This limits us to the "default" version of GHC in nixpkgs.
#
# With this in mind, we could simply use the `ghc` and `haskellPackages`
# package and package set, however the following has been written with
# flexibility in mind. Note that using `haskellPackages` implicitly brings the
# default version of GHC into scope as it's merely an alias for the default
# package set [1].
#
# Secondly, HLS is currently marked as broken on aarch64-darwin [2], which
# impacts Apple silicon contributors. With this in mind we're also keen to
# ensure that our chosen version of GHC is supported by HLS as distributed via
# ghcup.
#
# This means we're effectively stuck with whichever version of GHC is both the
# default for nixpkgs at some point in time - in the past is okay, as nixpkgs
# is pinned and the cache is long-lived - and which has the requisite support
# in ghcup as well. At time of writing that version is 9.4.6.
#
# Further complicating matters, GHC and HLS need to be sourced from the same
# place to ensure that HLS was compiled against that same version of GHC, lest
# we see "ABIs don't match" errors. Therefore aarch64-darwin contributors must
# not only source HLS externally but also GHC.
#
# In short, don't upgrade GHC until it's the default in nixpkgs, and available
# in ghcup and supported by HLS there as well.
#
# [1]: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/haskell.section.md#available-packages-haskell-available-packages
# [2]: https://github.com/NixOS/nixpkgs/blob/a410420844fe1ad6415cf9586308fe7538cc7584/pkgs/development/compilers/llvm/7/compiler-rt/default.nix#L108
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
Expand All @@ -41,27 +8,26 @@
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};

# We'll stick with the "default" version of GHC in nixpkgs to benefit
# from the binary cache:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/haskell.section.md#available-packages-haskell-available-packages
ghcVer = "ghc946";
haskPkgs = pkgs.haskell.packages."${ghcVer}";

hask = if system == flake-utils.lib.system.aarch64-darwin
then [ ]
else [
pkgs.haskell.compiler."${ghcVer}"
haskPkgs.haskell-language-server
];
haskPkgs = pkgs.haskell.packages."${ghcVer}";
in {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
cabal-install
haskell.compiler."${ghcVer}"
haskPkgs.haskell-language-server
hlint
haskPkgs.hspec-golden
stylish-haskell

# For typechecking golden output
nodejs
yarn
] ++ hask;
];
};
});
}

0 comments on commit d874b0f

Please sign in to comment.