2021-05-31 23:19:51 +00:00
|
|
|
{
|
2021-06-01 02:46:25 +00:00
|
|
|
description = "haskell-template's description";
|
2021-05-31 23:19:51 +00:00
|
|
|
inputs = {
|
2022-01-17 00:10:56 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/5aaed40d22f0d9376330b6fa413223435ad6fee5";
|
2021-05-31 23:19:51 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
|
2021-11-29 17:53:23 +00:00
|
|
|
flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system:
|
2021-05-31 23:19:51 +00:00
|
|
|
let
|
|
|
|
overlays = [ ];
|
|
|
|
pkgs =
|
|
|
|
import nixpkgs { inherit system overlays; config.allowBroken = true; };
|
2022-01-17 00:10:56 +00:00
|
|
|
hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921;
|
2021-12-05 21:46:03 +00:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/140774#issuecomment-976899227
|
|
|
|
m1MacHsBuildTools =
|
2022-01-17 00:10:56 +00:00
|
|
|
hp.override {
|
2021-12-05 21:46:03 +00:00
|
|
|
overrides = self: super:
|
|
|
|
let
|
|
|
|
workaround140774 = hpkg: with pkgs.haskell.lib;
|
|
|
|
overrideCabal hpkg (drv: {
|
|
|
|
enableSeparateBinOutput = false;
|
|
|
|
});
|
|
|
|
in
|
|
|
|
{
|
|
|
|
ghcid = workaround140774 super.ghcid;
|
|
|
|
ormolu = workaround140774 super.ormolu;
|
|
|
|
};
|
|
|
|
};
|
2021-05-31 23:19:51 +00:00
|
|
|
project = returnShellEnv:
|
2022-01-17 00:10:56 +00:00
|
|
|
hp.developPackage {
|
2021-05-31 23:19:51 +00:00
|
|
|
inherit returnShellEnv;
|
|
|
|
name = "haskell-template";
|
|
|
|
root = ./.;
|
|
|
|
withHoogle = false;
|
|
|
|
overrides = self: super: with pkgs.haskell.lib; {
|
2021-06-01 02:46:25 +00:00
|
|
|
# Use callCabal2nix to override Haskell dependencies here
|
|
|
|
# cf. https://tek.brick.do/K3VXJd8mEKO7
|
2022-01-08 16:39:25 +00:00
|
|
|
# Example:
|
|
|
|
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
|
|
|
|
# Assumes that you have the 'NanoID' flake input defined.
|
2021-05-31 23:19:51 +00:00
|
|
|
};
|
|
|
|
modifier = drv:
|
2021-12-05 21:46:03 +00:00
|
|
|
pkgs.haskell.lib.addBuildTools drv
|
|
|
|
(with (if system == "aarch64-darwin"
|
|
|
|
then m1MacHsBuildTools
|
2022-01-17 00:10:56 +00:00
|
|
|
else hp); [
|
2021-12-05 21:46:03 +00:00
|
|
|
# Specify your build/dev dependencies here.
|
|
|
|
cabal-fmt
|
|
|
|
cabal-install
|
|
|
|
ghcid
|
|
|
|
haskell-language-server
|
|
|
|
ormolu
|
|
|
|
pkgs.nixpkgs-fmt
|
|
|
|
]);
|
2021-05-31 23:19:51 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2021-06-01 02:46:25 +00:00
|
|
|
# Used by `nix build` & `nix run` (prod exe)
|
2021-05-31 23:19:51 +00:00
|
|
|
defaultPackage = project false;
|
|
|
|
|
2021-06-01 02:46:25 +00:00
|
|
|
# Used by `nix develop` (dev shell)
|
2021-05-31 23:19:51 +00:00
|
|
|
devShell = project true;
|
|
|
|
});
|
|
|
|
}
|