blob: 1d16b6219213d2bc82a774d4998280e71d30fd5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
'';
};
};
}
|