From 91a9e302fd485ad07fa8f3bf8967babcc556d042 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sun, 5 Dec 2021 16:46:03 -0500 Subject: [PATCH] Make 'nix develop' work on m1 mac --- flake.nix | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 3e93186..f7a3613 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,21 @@ overlays = [ ]; pkgs = import nixpkgs { inherit system overlays; config.allowBroken = true; }; + # https://github.com/NixOS/nixpkgs/issues/140774#issuecomment-976899227 + m1MacHsBuildTools = + pkgs.haskellPackages.override { + overrides = self: super: + let + workaround140774 = hpkg: with pkgs.haskell.lib; + overrideCabal hpkg (drv: { + enableSeparateBinOutput = false; + }); + in + { + ghcid = workaround140774 super.ghcid; + ormolu = workaround140774 super.ormolu; + }; + }; project = returnShellEnv: pkgs.haskellPackages.developPackage { inherit returnShellEnv; @@ -25,16 +40,18 @@ # cf. https://tek.brick.do/K3VXJd8mEKO7 }; modifier = drv: - pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; - [ - # Specify your build/dev dependencies here. - cabal-fmt - cabal-install - ghcid - haskell-language-server - ormolu - pkgs.nixpkgs-fmt - ]); + pkgs.haskell.lib.addBuildTools drv + (with (if system == "aarch64-darwin" + then m1MacHsBuildTools + else pkgs.haskellPackages); [ + # Specify your build/dev dependencies here. + cabal-fmt + cabal-install + ghcid + haskell-language-server + ormolu + pkgs.nixpkgs-fmt + ]); }; in {