From b907a39c413124021af6ef6653829fc48c11aeb1 Mon Sep 17 00:00:00 2001 From: Daniel Fainberg Date: Fri, 10 Jul 2026 09:00:33 +0200 Subject: [PATCH] feat(home): add pandoc with texlive for PDF output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit texlive scheme is the `local.texlive.package` option (default scheme-medium) so consumers can swap schemes without editing the module; TEXMF* vars keep its cache/config out of $HOME. pandoc PDF defaults to xelatex — pdflatex fails on combining Unicode (e.g. U+0308 in decomposed ä). Co-Authored-By: Claude Opus 4.8 --- modules/home.nix | 10 +++++++++- modules/texlive.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 modules/texlive.nix diff --git a/modules/home.nix b/modules/home.nix index 6735879..e85a505 100644 --- a/modules/home.nix +++ b/modules/home.nix @@ -71,7 +71,7 @@ let ''; in { - imports = [ ./gpg.nix ./media.nix ]; + imports = [ ./gpg.nix ./media.nix ./texlive.nix ]; # Put ~/.local/bin (the XDG user-bin dir) on PATH so hand-dropped scripts run # by name without wiring each through nix. @@ -185,6 +185,14 @@ in programs.home-manager.enable = true; + # Document converter (md/html/docx/…). PDF output shells out to a LaTeX engine + # (texlive.nix): default it to xelatex, which is Unicode-native — pdflatex + # (pandoc's own default) fails on combining marks, e.g. U+0308 in decomposed ä. + programs.pandoc = { + enable = true; + defaults.pdf-engine = "xelatex"; + }; + programs.git = { enable = true; settings = { diff --git a/modules/texlive.nix b/modules/texlive.nix new file mode 100644 index 0000000..bccc67f --- /dev/null +++ b/modules/texlive.nix @@ -0,0 +1,32 @@ +# TeX Live for pandoc PDF output: pandoc shells out to a LaTeX engine, so PDF +# conversion needs a TeX distribution (other formats — html, docx, md — do not). +# The package set is an option so a consumer can swap the scheme without editing +# this module: scheme-medium covers pandoc's default LaTeX template; override +# for a larger set (missing .sty files) or a smaller one. +# +# TeX Live's font cache and config trees default to ~/.texlive and ~/texmf +# (written on the first PDF build). The TEXMF* vars route them to XDG dirs. + +{ config, lib, pkgs, ... }: + +{ + options.local.texlive.package = lib.mkOption { + type = lib.types.package; + default = pkgs.texlive.withPackages (ps: [ ps.scheme-medium ]); + defaultText = lib.literalExpression + "pkgs.texlive.withPackages (ps: [ ps.scheme-medium ])"; + description = "TeX Live package set. Override for a larger/smaller scheme."; + }; + + config = { + home.packages = [ config.local.texlive.package ]; + + # texmf-var is regenerable font/format cache → cacheHome; the other two hold + # user config/data trees. + home.sessionVariables = { + TEXMFHOME = "${config.xdg.dataHome}/texmf"; + TEXMFVAR = "${config.xdg.cacheHome}/texlive/texmf-var"; + TEXMFCONFIG = "${config.xdg.configHome}/texlive/texmf-config"; + }; + }; +}