1# This Nix file can be handy when working on the github version of pandoc.
5# To run a nix shell with everthing needed to build pandoc with cabal:
7# To build pandoc for use on Linux and macOS systems without Nix:
10 import ((import <nixpkgs> {}).pkgs.fetchFromGitHub {
11 owner = "NixOS"; repo = "nixpkgs";
12 rev = "1354099daf98b7a1f79e6c41ce6bfda5c40177ae";
13 sha256 = "1dwnmxirzjrshlaan7cpag77y7nd09chrbakfx3c3f1lzsldbi97";
15let haskellPackages = pkgs.haskellPackages;
16 overrides = self: super: {
17 hslua-module-text = pkgs.haskell.lib.dontCheck
18 super.hslua-module-text;
19 skylighting = super.skylighting_0_5;
20 hslua = super.hslua_0_9_3;
23 doctemplates = "0.2.1";
25 pandoc-types = pkgs.fetchFromGitHub {
27 repo = "pandoc-types";
28 rev = "f1278603a4766f32b8375de84b8581f4bb1e665a";
29 sha256 = "05ykcs8qdjrxly9b6chjr939mv6r42mh51bl58k7jxsr1crxrrf9";
32 filterHaskellSource = src:
33 builtins.filterSource (path: type:
34 pkgs.lib.all (i: i != baseNameOf path) [ ".git" "dist-newstyle" "cabal.project.local" "dist" ".stack-work" ".DS_Store" "default.nix" "result" ]
35 && pkgs.lib.all (i: !(pkgs.lib.hasSuffix i path)) [ ".lkshf" ]
36 && pkgs.lib.all (i: !(pkgs.lib.hasPrefix i path)) [ ".ghc.environment." ]
39 # Normal nix derivation
41 haskellPackages.extend (
42 pkgs.lib.composeExtensions (
43 haskellPackages.packageSourceOverrides source-overrides
46 ).callCabal2nix "pandoc" (filterHaskellSource ./.) {};
48 # Like drv but with static linking for haskell libraries
49 static = pkgs.haskell.lib.justStaticExecutables (drv.overrideAttrs (old: {
50 buildInputs = old.buildInputs ++ [
52 haskellPackages.file-embed
56 "--disable-executable-dynamic"
60 # Patch binaries for use on macOS and linux systems without nix
61 # and bundle the required gmp and lua libraries
62 patched = pkgs.stdenv.mkDerivation {
63 name = "pandoc-patched";
71 installPhase = if pkgs.stdenv.isDarwin
74 cp ${static}/bin/pandoc $out/bin
75 cp ${pkgs.gmp}/lib/libgmp.10.dylib $out/bin
76 cp ${pkgs.lua5_3}/lib/liblua.5.3.4.dylib $out/bin
78 echo patching libgmp and liblua
79 install_name_tool -id "@executable_path/libgmp.10.dylib" "$out/bin/libgmp.10.dylib"
80 install_name_tool -id "@executable_path/liblua.5.3.4.dylib" "$out/bin/liblua.5.3.4.dylib"
81 for fn in $out/bin/*; do
83 install_name_tool -change "${pkgs.libiconv}/lib/libiconv.dylib" /usr/lib/libiconv.dylib "$fn"
84 install_name_tool -change "${pkgs.stdenv.libc}/lib/libSystem.B.dylib" /usr/lib/libSystem.B.dylib "$fn"
85 install_name_tool -change "${pkgs.gmp}/lib/libgmp.10.dylib" "@executable_path/libgmp.10.dylib" "$fn"
86 install_name_tool -change "${pkgs.lua5_3}/lib/liblua.5.3.4.dylib" "@executable_path/liblua.5.3.4.dylib" "$fn"
88 (cd $out/.. && zip -r $out/pandoc-macOS.zip `basename $out`/bin)
92 cp ${static}/bin/pandoc $out/bin
93 cp ${pkgs.gmp}/lib/libgmp.so* $out/bin
94 cp ${pkgs.lua5_3}/lib/liblua.so* $out/bin
95 chmod +w $out/bin/pandoc
96 patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $out/bin/pandoc
97 patchelf --set-rpath '$ORIGIN' $out/bin/pandoc
98 (cd $out/.. && tar -czf $out/pandoc-linux.tar.gz `basename $out`/bin)
101in if pkgs.lib.inNixShell then drv.env else drv // { inherit static patched; }
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list