about summary refs log tree commit diff
path: root/pkgs/applications/misc/gitit
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2024-06-06 12:49:13 +0200
committersternenseemann <sternenseemann@systemli.org>2024-06-07 11:18:28 +0200
commit8aae50acdacf70c5f601d05350a42eb08b6074d2 (patch)
tree3844cedfef32121959f4b4c89c7e11dca42097e8 /pkgs/applications/misc/gitit
parent2810884b1fc0664d97caf702ceb4e1d6b21df8c9 (diff)
gitit: fix build on aarch64-darwin
Diffstat (limited to 'pkgs/applications/misc/gitit')
-rw-r--r--pkgs/applications/misc/gitit/default.nix22
1 files changed, 20 insertions, 2 deletions
diff --git a/pkgs/applications/misc/gitit/default.nix b/pkgs/applications/misc/gitit/default.nix
index a22e65549d107..6958e1e6c59c2 100644
--- a/pkgs/applications/misc/gitit/default.nix
+++ b/pkgs/applications/misc/gitit/default.nix
@@ -1,4 +1,4 @@
-{ lib, haskellPackages, haskell
+{ 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
@@ -12,13 +12,31 @@ let
     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 justStaticExecutables base
+else lib.pipe (base.override { ghc-paths = null; }) [
+  justStaticExecutables
+  aarch64DarwinFix
+]