-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
69 lines (61 loc) · 2.47 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
let
ihp = builtins.fetchGit {
url = "https://github.com/digitallyinduced/ihp.git";
ref = "refs/tags/v0.17.0";
};
haskellLib = pkgs.haskell.lib;
manualOverrides = haskellPackagesNew: haskellPackagesOld:
{
# This function is called for building each haskell package.
# By overriding it here, we can pass in custom settings globally.
mkDerivation = args: haskellPackagesOld.mkDerivation (args // {
# enableLibraryProfiling = true;
# enableExecutableProfiling = true;
# doCheck = false;
# doHaddock = false;
# doHoogle = false;
});
# We don't want to enable profiling for build tools.
cabal2nix = haskellLib.disableLibraryProfiling (haskellLib.disableExecutableProfiling haskellPackagesOld.cabal2nix);
hackage2nix = haskellLib.disableLibraryProfiling (haskellLib.disableExecutableProfiling haskellPackagesOld.hackage2nix);
haskell-language-server = haskellLib.appendConfigureFlag haskellPackagesOld.haskell-language-server "--ghc-option=-eventlog";
# Marked broken, but works fine.
contiguous = haskellLib.unmarkBroken haskellPackagesOld.contiguous;
};
additionalNixpkgsOptions = { allowUnfree = true; };
pkgs = import "${toString ihp}/NixSupport/make-nixpkgs-from-options.nix" {
inherit ihp manualOverrides additionalNixpkgsOptions;
haskellPackagesDir = ./Config/nix/haskell-packages/.;
};
haskellPackages = pkgs.haskell.packages.ghc8107;
package = isProd:
(haskellPackages.callCabal2nixWithOptions
"App" # cabal file name
./. # source directory
(if isProd then "--flag Prod" else "") # cabal flags
{} # additional options
).overrideAttrs (oldAttrs: {
preBuild = (if (builtins.hasAttr "preBuild" oldAttrs) then oldAttrs.preBuild else "") + "${haskellPackages.ihp}/bin/build-generated-code";
installPhase = oldAttrs.installPhase + ''
mkdir -p $out/IHP $out/static
cp -r $src/static $out
cp -r ${haskellPackages.ihp}/lib/IHP/static $out/IHP
'';
});
in
if pkgs.lib.inNixShell
then
haskellPackages.shellFor {
packages = p: [
(package false)
];
buildInputs = with haskellPackages; [
pkgs.cabal-install
pkgs.postgresql
pkgs.haskell-language-server
ihp
];
withHoogle = true;
}
else
(package true)