serokell / nix-pandoc

An expression to build Pandoc documents with Nix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#

nix-pandoc

A wrapper around mkDerivation to build Pandoc documents with Nix

Basic usage

Put the following into your flake.nix:

{
  inputs = {
    nix-pandoc.url = "github:serokell/nix-pandoc";
    nix-pandoc.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs = { self, nixpkgs, nix-pandoc }: {
    defaultPackage = builtins.mapAttrs (system: pkgs: nix-pandoc.mkDoc.${system} {
      name = "your-document-name";
      src = ./.;
      phases = [ "unpackPhase" "buildPhase" "installPhase" ];
      buildPhase = "pandoc --pdf-engine=xelatex -o $name.pdf ./your-document.md";
      installPhase = "mkdir -p $out; cp $name.pdf $out";
    }) nixpkgs.legacyPackages;
  };
}

You may also want to place a Makefile in the root of your project that would contain instructions on how to build and install the files. If you do that, you can now do

{
  inputs = {
    nix-pandoc.url = "github:serokell/nix-pandoc";
    nix-pandoc.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs = { self, nixpkgs, nix-pandoc }: {
    defaultPackage = builtins.mapAttrs (system: pkgs: nix-pandoc.mkDoc.${system} {
      name = "your-document-name";
      src = ./.;
    }) nixpkgs.legacyPackages;
  };
}

You can run nix build to build your documents, or nix develop to get into a shell from where you can run make to build your documents more granularly.

Fonts

Pass a font argument to mkDoc containing the path to your font’s package (the font(s) must be located under share/fonts/).

More Texlive packages

You may build your own texlive distribution with texlive.combined and pass it to mkDoc as texlive-combined.

Extra TEX inputs

You may pass extraTexInputs, which should be a list of directories containing sty files that you may later use in your document.

License

This project is licensed under the Mozilla Public License, version 2.0; You may read more in ./LICENSE.

About Serokell

nix-pandoc is maintained and funded with ❤ by Serokell. The names and logo for Serokell are trademark of Serokell OÜ.

We love open source software! See our other projects or hire us to design, develop and grow your idea!

About

An expression to build Pandoc documents with Nix

License:Other


Languages

Language:Nix 80.7%Language:Makefile 19.3%