about summary refs log tree commit diff
path: root/pkgs/applications/misc/gitit/default.nix
blob: 6958e1e6c59c2cbfbf4d5fc3f5df6a355d4d3021 (plain) (blame)
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
{ lib, stdenv, haskellPackages, haskell
# “Plugins” are a fancy way of saying gitit will invoke
# GHC at *runtime*, which in turn makes it pull GHC
# into its runtime closure. Only enable if you really need
# that feature. But if you do you’ll want to use gitit
# as a library anyway.
, pluginSupport ? false
}:

let
  inherit (haskell.lib.compose)
    enableCabalFlag
    disableCabalFlag
    justStaticExecutables
    overrideCabal
  ;

  base = (if pluginSupport then enableCabalFlag else disableCabalFlag)
    "plugins"
    haskellPackages.gitit;

  # Removes erroneous references from dead code that GHC can't eliminate
  aarch64DarwinFix = overrideCabal (drv:
    lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) {
      postInstall = ''
        ${drv.postInstall or ""}
        remove-references-to -t ${haskellPackages.HTTP} "$out/bin/gitit"
        remove-references-to -t ${haskellPackages.HTTP} "$out/bin/expireGititCache"
        remove-references-to -t ${haskellPackages.happstack-server} "$out/bin/gitit"
        remove-references-to -t ${haskellPackages.hoauth2} "$out/bin/gitit"
        remove-references-to -t ${haskellPackages.pandoc} "$out/bin/gitit"
        remove-references-to -t ${haskellPackages.pandoc-types} "$out/bin/gitit"
      '';
    });
in

if pluginSupport
then base
else lib.pipe (base.override { ghc-paths = null; }) [
  justStaticExecutables
  aarch64DarwinFix
]