summaryrefslogtreecommitdiff
path: root/publications/default.nix
blob: 4c7189fdff695a441a821a02e2cced276c332ce2 (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
28
29
30
{
  pkgs,
  lib,
  ...
}: let
  csl = lib.importJSON ./publications.json;
  export = id: publication: format: let
    publicationJSON =
      builtins.toFile "${id}.json" (builtins.toJSON [publication]);
    publicationOut = pkgs.runCommand "${id}.${format}" {} ''
      "${pkgs.pandoc}/bin/pandoc" "${publicationJSON}" --from csljson --to "${format}" --output "$out"
    '';
  in
    builtins.readFile publicationOut;
in
  builtins.map (publication:
    with publication; let
      exportThisTo = export id publication;
    in
      publication
      // {
        year = with builtins; toString (head (head issued.date-parts));
        url = URL;
        cite = {
          bibtex = exportThisTo "bibtex";
          biblatex = exportThisTo "biblatex";
          csljson = exportThisTo "csljson";
        };
      })
  csl