1{ lib, stdenv, haskellPackages, haskell
2# “Plugins” are a fancy way of saying gitit will invoke
3# GHC at *runtime*, which in turn makes it pull GHC
4# into its runtime closure. Only enable if you really need
5# that feature. But if you do you’ll want to use gitit
6# as a library anyway.
7, pluginSupport ? false
8}:
9
10let
11 inherit (haskell.lib.compose)
12 enableCabalFlag
13 disableCabalFlag
14 justStaticExecutables
15 overrideCabal
16 ;
17
18 base = (if pluginSupport then enableCabalFlag else disableCabalFlag)
19 "plugins"
20 haskellPackages.gitit;
21
22 # Removes erroneous references from dead code that GHC can't eliminate
23 aarch64DarwinFix = overrideCabal (drv:
24 lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) {
25 postInstall = ''
26 ${drv.postInstall or ""}
27 remove-references-to -t ${haskellPackages.HTTP} "$out/bin/gitit"
28 remove-references-to -t ${haskellPackages.HTTP} "$out/bin/expireGititCache"
29 remove-references-to -t ${haskellPackages.happstack-server} "$out/bin/gitit"
30 remove-references-to -t ${haskellPackages.hoauth2} "$out/bin/gitit"
31 remove-references-to -t ${haskellPackages.pandoc} "$out/bin/gitit"
32 remove-references-to -t ${haskellPackages.pandoc-types} "$out/bin/gitit"
33 '';
34 });
35in
36
37if pluginSupport
38then base
39else lib.pipe (base.override { ghc-paths = null; }) [
40 justStaticExecutables
41 aarch64DarwinFix
42]