From 804533cde06189bb2109c063092d59b2d53ee4db Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 16 Mar 2025 17:15:39 +0100 Subject: ... --- home-modules/pandoc/default.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 home-modules/pandoc/default.nix (limited to 'home-modules/pandoc/default.nix') diff --git a/home-modules/pandoc/default.nix b/home-modules/pandoc/default.nix new file mode 100644 index 00000000..1d16b621 --- /dev/null +++ b/home-modules/pandoc/default.nix @@ -0,0 +1,27 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.programs.pandoc; +in { + options.programs.pandoc = { + germanAbbreviations = lib.mkEnableOption "importing german abbreviations" // { default = true; }; + extraAbbreviations = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + }; + }; + + config = lib.mkIf cfg.enable { + xdg.dataFile = lib.mkIf (cfg.germanAbbreviations || cfg.extraAbbreviations != []) { + "pandoc/abbreviations".source = pkgs.runCommand "pandoc-abbreviations" { + buildInputs = [ pkgs.coreutils ]; + } '' + cat \ + <(${lib.getExe' cfg.finalPackage "pandoc"} --print-default-data-file=abbreviations) \ + ${lib.optionalString cfg.germanAbbreviations ./german_abbreviations.txt} \ + ${lib.optionalString (cfg.extraAbbreviations != []) (pkgs.writeText "abbrevs.txt" (lib.concatStringsSep "\n" cfg.extraAbbreviations))} \ + | sort | uniq >$out + ''; + }; + }; +} -- cgit v1.2.3