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