From 102ed4e7d78dd17ce8ce9e0b928f5123e94d0cfa Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Fri, 11 Nov 2022 17:27:34 +0100 Subject: add initial data --- publications/default.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 publications/default.nix (limited to 'publications/default.nix') diff --git a/publications/default.nix b/publications/default.nix new file mode 100644 index 0000000..2c85dff --- /dev/null +++ b/publications/default.nix @@ -0,0 +1,29 @@ +{ 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; + tryInherit = inheritFrom: attrs: + with lib; + foldl' (tmp: next: + tmp ++ optional (hasAttr next inheritFrom) (getAttr next inheritFrom)) [ ] + attrs; +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 -- cgit v1.2.3