Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit a9d9ac2
Merge: 80f2ab3 c686098
Author: Gabriella Gonzalez <[email protected]>
Date:   Tue Feb 21 16:36:19 2023 -0800

    Merge branch 'master' into gabriella/fix_build

commit 80f2ab3
Author: Gabriella Gonzalez <[email protected]>
Date:   Fri Feb 10 10:29:37 2023 -0800

    Fix hash

commit 46dc419
Merge: 2d2b8e8 84e4f9c
Author: Gabriella Gonzalez <[email protected]>
Date:   Fri Feb 10 10:04:33 2023 -0800

    Merge branch 'master' into gabriella/fix_build

commit 2d2b8e8
Author: Gabriella Gonzalez <[email protected]>
Date:   Thu Feb 2 12:50:40 2023 -0800

    Fix build failures on `aarch64-darwin`

    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
supersven committed Feb 24, 2023
1 parent c686098 commit 8fb3adb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 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.

8 changes: 2 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
outputs = { self, nixpkgs, nixpkgs-unstable, all-cabal-hashes, ... }: with nixpkgs.lib; let
supportedSystems = systems.flakeExposed;
perSystem = genAttrs supportedSystems;
pkgsFor = system: import nixpkgs { inherit system; };
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 All @@ -40,7 +36,7 @@
ghc-nix = import ./ghc.nix (defaultSettings system // userSettings);
default = ghc-nix;
});
formatter = perSystem (system: (pkgsFor system).nixpkgs-fmt);
formatter = perSystem (system: (import nixpkgs { inherit system; }).nixpkgs-fmt);

# NOTE: this attribute is used by the flake-compat code to allow passing arguments to ./ghc.nix
legacy = args: import ./ghc.nix (defaultSettings args.system // args);
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 8fb3adb

Please sign in to comment.