diff options
Diffstat (limited to 'research')
| -rw-r--r-- | research/default.nix | 42 | ||||
| -rw-r--r-- | research/export.nix | 35 |
2 files changed, 48 insertions, 29 deletions
diff --git a/research/default.nix b/research/default.nix index 8de25f8..90f0471 100644 --- a/research/default.nix +++ b/research/default.nix @@ -2,19 +2,31 @@ pkgs, lib, ... -}: let - importPublications = builtins.map (publication: - with publication; - publication - // { - year = with builtins; toString (head (head issued.date-parts)); - url = URL; - }); -in { - conferences = importPublications (lib.importJSON ./conferences.json); - journals = importPublications (lib.importJSON ./journals.json); - reports = importPublications (lib.importJSON ./reports.json); - misc = importPublications (lib.importJSON ./miscellaneous.json); - talks = importPublications (lib.importJSON ./talks.json); - files = pkgs.callPackage ./export.nix {refsJSON = lib.concatStringsSep " " [./conferences.json ./journals.json ./reports.json ./miscellaneous.json ./talks.json];}; +}: +let + importResearch = builtins.map ( + researchItem: + with researchItem; + researchItem + // { + year = with builtins; toString (head (head issued.date-parts)); + url = URL; + } + ); +in +{ + conferences = importResearch (lib.importJSON ./conferences.json); + journals = importResearch (lib.importJSON ./journals.json); + reports = importResearch (lib.importJSON ./reports.json); + misc = importResearch (lib.importJSON ./miscellaneous.json); + talks = importResearch (lib.importJSON ./talks.json); + files = pkgs.callPackage ./export.nix { + refsJSON = lib.concatStringsSep " " [ + ./conferences.json + ./journals.json + ./reports.json + ./miscellaneous.json + ./talks.json + ]; + }; } diff --git a/research/export.nix b/research/export.nix index b119054..22c965d 100644 --- a/research/export.nix +++ b/research/export.nix @@ -4,20 +4,27 @@ refsJSON, runCommand, }: -runCommand "publications" {buildInputs = [jq pandoc];} '' - mkdir -p "$out"/{biblatex,bibtex,csljson} - cd "$out" +runCommand "export-research-bib" + { + buildInputs = [ + jq + pandoc + ]; + } + '' + mkdir -p "$out"/{biblatex,bibtex,csljson} + cd "$out" - for refs in ${refsJSON} - do - jq --compact-output ".[]" $refs | while read -r ref + for refs in ${refsJSON} 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 ]" + jq --compact-output ".[]" $refs | while read -r 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 done - done -'' + '' |
