1 { stdenv, lib, haskellPackages, haskell, removeReferencesTo, installShellFiles }:
4 # Since pandoc 3.0 the pandoc binary resides in the pandoc-cli package.
5 static = haskell.lib.compose.justStaticExecutables haskellPackages.pandoc-cli;
8 (haskell.lib.compose.overrideCabal (drv: {
9 configureFlags = drv.configureFlags or [] ++ ["-fembed_data_files"];
10 buildDepends = drv.buildDepends or [] ++ [haskellPackages.file-embed];
11 buildTools = (drv.buildTools or []) ++ [
16 # Normally, the static linked executable shouldn't refer to any library or the compiler.
17 # This is not always the case when the dependency has Paths_* module generated by Cabal,
18 # where bindir, datadir, and libdir contain the path to the library, and thus make the
19 # executable indirectly refer to GHC. However, most Haskell programs only use Paths_*.version for
20 # getting the version at runtime, so it's safe to remove the references to them.
21 # This is true so far for pandoc-types and warp.
22 # For details see: https://github.com/NixOS/nixpkgs/issues/34376
23 postInstall = drv.postInstall or "" + ''
24 remove-references-to \
25 -t ${haskellPackages.pandoc-types} \
27 remove-references-to \
28 -t ${haskellPackages.warp} \
30 remove-references-to \
31 -t ${haskellPackages.pandoc} \
33 '' + lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform) ''
34 mkdir -p $out/share/bash-completion/completions
35 $out/bin/pandoc --bash-completion > $out/share/bash-completion/completions/pandoc
39 }) static).overrideAttrs (drv: {
40 # These libraries are still referenced, because they generate
41 # a `Paths_*` module for figuring out their version.
42 # The `Paths_*` module is generated by Cabal, and contains the
43 # version, but also paths to e.g. the data directories, which
44 # lead to a transitive runtime dependency on the whole GHC distribution.
45 # This should ideally be fixed in haskellPackages (or even Cabal),
46 # but a minimal pandoc is important enough to patch it manually.
47 disallowedReferences = [ haskellPackages.pandoc-types haskellPackages.warp haskellPackages.pandoc ];