matrix-media-expanded/flake.nix
2022-01-30 12:05:58 -05:00

68 lines
2.3 KiB
Nix

{
description = "haskell-template's description";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/5efc8ca954272c4376ac929f4c5ffefcc20551d5";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ ];
pkgs =
import nixpkgs { inherit system overlays; config.allowBroken = true; };
hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921;
# https://github.com/NixOS/nixpkgs/issues/140774#issuecomment-976899227
m1MacHsBuildTools =
hp.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:
hp.developPackage {
inherit returnShellEnv;
name = "haskell-template";
root = ./.;
withHoogle = false;
overrides = self: super: with pkgs.haskell.lib; {
# Use callCabal2nix to override Haskell dependencies here
# cf. https://tek.brick.do/K3VXJd8mEKO7
# Example:
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
# Assumes that you have the 'NanoID' flake input defined.
};
modifier = drv:
pkgs.haskell.lib.addBuildTools drv
(with (if system == "aarch64-darwin"
then m1MacHsBuildTools
else hp); [
# Specify your build/dev dependencies here.
cabal-fmt
cabal-install
ghcid
haskell-language-server
ormolu
pkgs.nixpkgs-fmt
]);
};
in
{
# Used by `nix build` & `nix run` (prod exe)
defaultPackage = project false;
# Used by `nix develop` (dev shell)
devShell = project true;
});
}