1# This Nix file can be handy when working on the github version of pandoc.
5# To run a nix shell with everything 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 = "42b9b8f7c8687cb26e69c3559e0e1346fb0e680f";
13 sha256 = "01zcd0dh9x3qf5yflclbrcvff9yh8k9pmccc7vjlq3phc440qsyb";
15let haskellPackages = pkgs.haskellPackages;
16 overrides = self: super: { };
18 doctemplates = "0.2.1";
20 pandoc-types = pkgs.fetchFromGitHub {
22 repo = "pandoc-types";
23 rev = "f1278603a4766f32b8375de84b8581f4bb1e665a";
24 sha256 = "05ykcs8qdjrxly9b6chjr939mv6r42mh51bl58k7jxsr1crxrrf9";
27 filterHaskellSource = src:
28 builtins.filterSource (path: type:
29 pkgs.lib.all (i: i != baseNameOf path) [ ".git" "dist-newstyle" "cabal.project.local" "dist" ".stack-work" ".DS_Store" "default.nix" "result" ]
30 && pkgs.lib.all (i: !(pkgs.lib.hasSuffix i path)) [ ".lkshf" ]
31 && pkgs.lib.all (i: !(pkgs.lib.hasPrefix i path)) [ ".ghc.environment." ]
34 # Normal nix derivation
36 haskellPackages.extend (
37 pkgs.lib.composeExtensions (
38 haskellPackages.packageSourceOverrides source-overrides
41 ).callCabal2nix "pandoc" (filterHaskellSource ./.) {};
43 # Like drv but with static linking for haskell libraries
44 static = pkgs.haskell.lib.justStaticExecutables (drv.overrideAttrs (old: {
45 buildInputs = old.buildInputs ++ [
47 haskellPackages.file-embed
51 "--disable-executable-dynamic"
55 # Patch binaries for use on macOS and linux systems without nix
56 # and bundle the required gmp and lua libraries
57 patched = pkgs.stdenv.mkDerivation {
58 name = "pandoc-patched";
66 installPhase = if pkgs.stdenv.isDarwin
69 cp ${static}/bin/pandoc $out/bin
70 cp ${pkgs.gmp}/lib/libgmp.10.dylib $out/bin
71 cp ${pkgs.lua5_3}/lib/liblua.5.3.4.dylib $out/bin
73 echo patching libgmp and liblua
74 install_name_tool -id "@executable_path/libgmp.10.dylib" "$out/bin/libgmp.10.dylib"
75 install_name_tool -id "@executable_path/liblua.5.3.4.dylib" "$out/bin/liblua.5.3.4.dylib"
76 for fn in $out/bin/*; do
78 install_name_tool -change "${pkgs.libiconv}/lib/libiconv.dylib" /usr/lib/libiconv.dylib "$fn"
79 install_name_tool -change "${pkgs.stdenv.libc}/lib/libSystem.B.dylib" /usr/lib/libSystem.B.dylib "$fn"
80 install_name_tool -change "${pkgs.gmp}/lib/libgmp.10.dylib" "@executable_path/libgmp.10.dylib" "$fn"
81 install_name_tool -change "${pkgs.lua5_3}/lib/liblua.5.3.4.dylib" "@executable_path/liblua.5.3.4.dylib" "$fn"
83 (cd $out/.. && zip -r $out/pandoc-macOS.zip `basename $out`/bin)
87 cp ${static}/bin/pandoc $out/bin
88 cp ${pkgs.gmp}/lib/libgmp.so* $out/bin
89 cp ${pkgs.lua5_3}/lib/liblua.so* $out/bin
90 chmod +w $out/bin/pandoc
91 patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $out/bin/pandoc
92 patchelf --set-rpath '$ORIGIN' $out/bin/pandoc
93 (cd $out/.. && tar -czf $out/pandoc-linux.tar.gz `basename $out`/bin)
96in 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