Skip to content

Commit

Permalink
Fix build failures on aarch64-darwin
Browse files Browse the repository at this point in the history
The main change here is enabling the separate `bin`
output for `ormolu`, which is currently necessary to get
HLS working on `aarch64-darwin`.  See:

NixOS/nixpkgs#140774 (comment)

Adding in the overlay to fix that entailed some surgery to
`ghc.nix` and `flake.nix`, but I tried my best to make it as
unintrusive as possible.
  • Loading branch information
Gabriella439 authored and supersven committed Feb 24, 2023
1 parent d5c78ed commit 41992d6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
unstablePkgsFor = system: import nixpkgs-unstable { inherit system; };

defaultSettings = system: {
inherit system;
inherit nixpkgs nixpkgs-unstable system;
all-cabal-hashes = all-cabal-hashes.outPath;
nixpkgs = pkgsFor system;
nixpkgs-unstable = unstablePkgsFor system;
};

# NOTE: change this according to the settings allowed in the ./ghc.nix file and described
Expand Down
60 changes: 48 additions & 12 deletions ghc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# nix-shell path/to/ghc.nix/ --run 'hadrian/build -c -j4 --flavour=quickest'
# nix-shell path/to/ghc.nix/ --run 'THREADS=4 ./validate --slow'
#
let
pkgsFor = nixpkgs: system:
import nixpkgs { inherit system; overlays = [ ]; config = { }; };

in

{ system ? builtins.currentSystem
, nixpkgs
, nixpkgs-unstable
Expand All @@ -17,14 +23,44 @@
, withGhcid ? false
, withIde ? false
, withHadrianDeps ? false
, withDwarf ? nixpkgs.stdenv.isLinux # enable libdw unwinding support
, withNuma ? nixpkgs.stdenv.isLinux
, withDtrace ? nixpkgs.stdenv.isLinux
, withGrind ? !(nixpkgs.valgrind.meta.broken or false)
, withDwarf ? (pkgsFor nixpkgs system).stdenv.isLinux # enable libdw unwinding support
, withNuma ? (pkgsFor nixpkgs system).stdenv.isLinux
, withDtrace ? (pkgsFor nixpkgs system).stdenv.isLinux
, withGrind ? !((pkgsFor nixpkgs system).valgrind.meta.broken or false)
, withEMSDK ? false # load emscripten for js-backend
}:

with nixpkgs;
let
overlay = self: super: {
haskell = super.haskell // {
packages = super.haskell.packages // {
${bootghc} = super.haskell.packages.${bootghc}.override (old: {
inherit all-cabal-hashes;
overrides =
self.lib.composeExtensions
(old.overrides or (_: _: {}))
(hself: hsuper: {
ormolu =
if self.system == "aarch64-darwin"
then
self.haskell.lib.overrideCabal
hsuper.ormolu
(_: { enableSeparateBinOutput = false; })
else
hsuper.ormolu;
});
});
};
};
};

pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };

pkgs-unstable =
import nixpkgs-unstable { inherit system; overlays = [ overlay ]; };
in

with pkgs;

let
llvmForGhc =
Expand All @@ -34,8 +70,8 @@ let

stdenv =
if useClang
then nixpkgs.clangStdenv
else nixpkgs.stdenv;
then pkgs.clangStdenv
else pkgs.stdenv;
noTest = pkg: haskell.lib.dontCheck pkg;

hspkgs = haskell.packages.${bootghc}.override {
Expand All @@ -45,12 +81,12 @@ let
ghc = haskell.compiler.${bootghc};

ourtexlive =
nixpkgs.texlive.combine {
inherit (nixpkgs.texlive)
pkgs.texlive.combine {
inherit (pkgs.texlive)
scheme-medium collection-xetex fncychap titlesec tabulary varwidth
framed capt-of wrapfig needspace dejavu-otf helvetic upquote;
};
fonts = nixpkgs.makeFontsConf { fontDirectories = [ nixpkgs.dejavu_fonts ]; };
fonts = pkgs.makeFontsConf { fontDirectories = [ pkgs.dejavu_fonts ]; };
docsPackages = if withDocs then [ python3Packages.sphinx ourtexlive ] else [ ];

depsSystem = with lib; (
Expand Down Expand Up @@ -81,8 +117,8 @@ let
++ optional withNuma numactl
++ optional withDwarf elfutils
++ optional withGhcid ghcid
++ optional withIde (nixpkgs-unstable.haskell-language-server.override { supportedGhcVersions = [ (builtins.replaceStrings [ "." ] [ "" ] ghc.version) ]; })
++ optional withIde nixpkgs-unstable.clang-tools # N.B. clang-tools for clangd
++ optional withIde (pkgs-unstable.haskell-language-server.override { supportedGhcVersions = [ (builtins.replaceStrings [ "." ] [ "" ] ghc.version) ]; })
++ optional withIde pkgs-unstable.clang-tools # N.B. clang-tools for clangd
++ optional withDtrace linuxPackages.systemtap
++ (if (! stdenv.isDarwin)
then [ pxz ]
Expand Down

0 comments on commit 41992d6

Please sign in to comment.