diff options
Diffstat (limited to 'home-modules/pandoc/default.nix')
| -rw-r--r-- | home-modules/pandoc/default.nix | 27 |
1 files changed, 27 insertions, 0 deletions
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 @@ | |||
| 1 | { pkgs, lib, config, ... }: | ||
| 2 | |||
| 3 | let | ||
| 4 | cfg = config.programs.pandoc; | ||
| 5 | in { | ||
| 6 | options.programs.pandoc = { | ||
| 7 | germanAbbreviations = lib.mkEnableOption "importing german abbreviations" // { default = true; }; | ||
| 8 | extraAbbreviations = lib.mkOption { | ||
| 9 | type = lib.types.listOf lib.types.str; | ||
| 10 | default = []; | ||
| 11 | }; | ||
| 12 | }; | ||
| 13 | |||
| 14 | config = lib.mkIf cfg.enable { | ||
| 15 | xdg.dataFile = lib.mkIf (cfg.germanAbbreviations || cfg.extraAbbreviations != []) { | ||
| 16 | "pandoc/abbreviations".source = pkgs.runCommand "pandoc-abbreviations" { | ||
| 17 | buildInputs = [ pkgs.coreutils ]; | ||
| 18 | } '' | ||
| 19 | cat \ | ||
| 20 | <(${lib.getExe' cfg.finalPackage "pandoc"} --print-default-data-file=abbreviations) \ | ||
| 21 | ${lib.optionalString cfg.germanAbbreviations ./german_abbreviations.txt} \ | ||
| 22 | ${lib.optionalString (cfg.extraAbbreviations != []) (pkgs.writeText "abbrevs.txt" (lib.concatStringsSep "\n" cfg.extraAbbreviations))} \ | ||
| 23 | | sort | uniq >$out | ||
| 24 | ''; | ||
| 25 | }; | ||
| 26 | }; | ||
| 27 | } | ||
