summaryrefslogtreecommitdiff
path: root/publications
diff options
context:
space:
mode:
Diffstat (limited to 'publications')
-rw-r--r--publications/default.nix18
-rw-r--r--publications/export.nix20
2 files changed, 22 insertions, 16 deletions
diff --git a/publications/default.nix b/publications/default.nix
index 0c13869..d41555c 100644
--- a/publications/default.nix
+++ b/publications/default.nix
@@ -3,29 +3,15 @@
lib,
...
}: let
- 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;
importPublications = builtins.map (publication:
- with publication; let
- exportThisTo = export id publication;
- in
+ with publication;
publication
// {
year = with builtins; toString (head (head issued.date-parts));
url = URL;
- cite = {
- bibtex = exportThisTo "bibtex";
- biblatex = exportThisTo "biblatex";
- csljson = exportThisTo "csljson";
- };
});
in {
selected = importPublications (lib.importJSON ./publications_selected.json);
all = importPublications (lib.importJSON ./publications.json);
+ files = pkgs.callPackage ./export.nix {};
}
diff --git a/publications/export.nix b/publications/export.nix
new file mode 100644
index 0000000..6a6c42d
--- /dev/null
+++ b/publications/export.nix
@@ -0,0 +1,20 @@
+{
+ jq,
+ pandoc,
+ refsJSON ? ./publications.json,
+ runCommand,
+}:
+runCommand "publications" {buildInputs = [jq pandoc];} ''
+ mkdir -p "$out"/{biblatex,bibtex,csljson}
+ cd "$out"
+
+ jq --compact-output ".[]" ${refsJSON} | while read ref
+ do
+ id=$(echo "$ref" | jq --raw-output '.id')
+ echo $id
+ echo "$ref" > "csljson/$id"
+ cat csljson/$id
+ pandoc --from=csljson --to=biblatex --output "biblatex/$id" <<< "[ $ref ]"
+ pandoc --from=csljson --to=bibtex --output "bibtex/$id" <<< "[ $ref ]"
+ done
+''