diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2023-09-17 20:17:50 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2023-09-17 20:18:54 +0200 |
| commit | 01123862c6bd3ef3c5b9d732f63670d7fb1cfefa (patch) | |
| tree | 1129365241bf2e3313d8077826964f6653a782c7 | |
| parent | 360c8a636b8f51c45689cc1518a628383f24420b (diff) | |
reformat
| -rw-r--r-- | lib/default.nix | 6 | ||||
| -rw-r--r-- | lib/latex.nix | 160 | ||||
| -rw-r--r-- | src/default.nix | 49 | ||||
| -rw-r--r-- | src/education/default.nix | 31 | ||||
| -rw-r--r-- | src/experience/default.nix | 27 | ||||
| -rw-r--r-- | src/languages/default.nix | 22 | ||||
| -rw-r--r-- | src/publications/default.nix | 10 | ||||
| -rw-r--r-- | src/sections.nix | 28 |
8 files changed, 181 insertions, 152 deletions
diff --git a/lib/default.nix b/lib/default.nix index 57653ad..6926374 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,3 @@ -{ lib }: - -{ - pp.latex = import ./latex.nix { inherit lib; }; +{lib}: { + pp.latex = import ./latex.nix {inherit lib;}; } diff --git a/lib/latex.nix b/lib/latex.nix index 99cd783..1524620 100644 --- a/lib/latex.nix +++ b/lib/latex.nix @@ -1,51 +1,47 @@ -{ lib, ... }: - -let +{lib, ...}: let lines = content: - if lib.isList content then - (if content == [ ] then - "" - else - lines (builtins.head content) + "\n" + lines (builtins.tail content)) - else - content; + if lib.isList content + then + ( + if content == [] + then "" + else lines (builtins.head content) + "\n" + lines (builtins.tail content) + ) + else content; sortByFun = cmp: f: lib.sort (x: y: cmp (f x) (f y)); sortByPath = cmp: keys: sortByFun cmp (lib.getAttrFromPath keys); - sortByKey = cmp: key: sortByPath cmp [ key ]; + sortByKey = cmp: key: sortByPath cmp [key]; for = iterable: f: - if lib.isList iterable then - builtins.map f iterable - else - lib.mapAttrsToList f iterable; - - tryOverride = f: arg: - if lib.isAttrs arg then - tryOverride (attrs: content: f (arg // attrs) content) - else - f { } arg; + if lib.isList iterable + then builtins.map f iterable + else lib.mapAttrsToList f iterable; setOptionalArg = name: value: "${name}=${value}"; expandArgsPrefixed = numArgs: prefix: - if numArgs <= 0 then - prefix + if numArgs <= 0 + then prefix else - arg: - let - appendToPrefix = if lib.isAttrs arg then - "[" + lib.concatStringsSep "," (lib.mapAttrsToList setOptionalArg arg) - + "]" - else - "{${arg}}"; - newNumArgs = if lib.isAttrs arg then numArgs else numArgs - 1; - in expandArgsPrefixed newNumArgs (prefix + appendToPrefix); + arg: let + appendToPrefix = + if lib.isAttrs arg + then + "[" + + lib.concatStringsSep "," (lib.mapAttrsToList setOptionalArg arg) + + "]" + else "{${arg}}"; + newNumArgs = + if lib.isAttrs arg + then numArgs + else numArgs - 1; + in + expandArgsPrefixed newNumArgs (prefix + appendToPrefix); macroWithOpts = name: numArgs: expandArgsPrefixed numArgs "\\${name}"; - macro = name: content: - let - contentExpanded = if lib.isList content then - lib.concatStringsSep "}{" content - else - content; - in "\\${name}{${contentExpanded}}"; + macro = name: content: let + contentExpanded = + if lib.isList content + then lib.concatStringsSep "}{" content + else content; + in "\\${name}{${contentExpanded}}"; sectionMacro = type: name: content: '' \${type}{${name}} @@ -76,7 +72,7 @@ let email = macroWithOpts "email" 1; extrainfo = macroWithOpts "extrainfo" 1; photo = macroWithOpts "photo" 1; - makecvtitle = macro "makecvtitle" [ ]; + makecvtitle = macro "makecvtitle" []; cventry = macroWithOpts "cventry" 6; cvlistitem = macroWithOpts "cvlistitem" 1; cvline = macroWithOpts "cvline" 2; @@ -87,47 +83,49 @@ let file = path: "files/${path}"; href = latex.href; - timerange = startdate: enddate: - let - print = builtins.mapAttrs (name: x: builtins.toString x); - # let str = builtins.toString x; - # in if name == "year" then - # builtins.substring 2 4 str - # else - # (if name == "month" && x < 10 then "0${str}" else str)); - start = print startdate; - end = print enddate; - months = { - "1" = "jan"; - "2" = "feb"; - "3" = "mar"; - "4" = "apr"; - "5" = "may"; - "6" = "jun"; - "7" = "jul"; - "8" = "aug"; - "9" = "sep"; - "10" = "oct"; - "11" = "nov"; - "12" = "dec"; - }; - in "${months."${start.month}"}." + timerange = startdate: enddate: let + print = builtins.mapAttrs (_: x: builtins.toString x); + # let str = builtins.toString x; + # in if name == "year" then + # builtins.substring 2 4 str + # else + # (if name == "month" && x < 10 then "0${str}" else str)); + start = print startdate; + end = print enddate; + months = { + "1" = "jan"; + "2" = "feb"; + "3" = "mar"; + "4" = "apr"; + "5" = "may"; + "6" = "jun"; + "7" = "jul"; + "8" = "aug"; + "9" = "sep"; + "10" = "oct"; + "11" = "nov"; + "12" = "dec"; + }; + in + "${months."${start.month}"}." + lib.optionalString (start.year != end.year) " ${start.year}" + " -- ${months."${end.month}"}. ${end.year}"; -in latex // { - inherit for file href lines timerange; - code = x: x; - sort = let - lt = x: y: x < y; - gt = x: y: x > y; - in { - byKey = sortByKey lt; - byPath = sortByPath lt; - byFun = sortByFun lt; - reverse = { - byKey = sortByKey gt; - byPath = sortByPath gt; - byFun = sortByFun gt; +in + latex + // { + inherit for file href lines timerange; + code = x: x; + sort = let + lt = x: y: x < y; + gt = x: y: x > y; + in { + byKey = sortByKey lt; + byPath = sortByPath lt; + byFun = sortByFun lt; + reverse = { + byKey = sortByKey gt; + byPath = sortByPath gt; + byFun = sortByFun gt; + }; }; - }; -} + } diff --git a/src/default.nix b/src/default.nix index 421367b..e698a93 100644 --- a/src/default.nix +++ b/src/default.nix @@ -1,22 +1,27 @@ -{ latex, data, make, ... }: - -with latex; -let sections = sort.byKey "priority" (make ./sections.nix { }); -in with data.basics; -lines [ - (builtins.readFile ./header.tex) - (comment "-------------------- EXTRA --------------------") - (for sections (section: section.extraHeader)) - (comment "-------------------- DATA --------------------") - (moderncv.name name.first name.last) - (moderncv.email email.personal) - (moderncv.extrainfo (latex.url url)) - (moderncv.photo { "" = "128pt"; } avatar) - "" - (document [ - (title institution.position) - moderncv.makecvtitle - description - (for sections (section: section.content)) - ]) -] +{ + latex, + data, + make, + ... +}: +with latex; let + sections = sort.byKey "priority" (make ./sections.nix {}); +in + with data.basics; + lines [ + (builtins.readFile ./header.tex) + (comment "-------------------- EXTRA --------------------") + (for sections (section: section.extraHeader)) + (comment "-------------------- DATA --------------------") + (moderncv.name name.first name.last) + (moderncv.email email.personal) + (moderncv.extrainfo (latex.url url)) + (moderncv.photo {"" = "128pt";} avatar) + "" + (document [ + (title institution.position) + moderncv.makecvtitle + description + (for sections (section: section.content)) + ]) + ] diff --git a/src/education/default.nix b/src/education/default.nix index 5b79323..2d46730 100644 --- a/src/education/default.nix +++ b/src/education/default.nix @@ -1,8 +1,12 @@ -{ latex, data, lib, ... }: - -let +{ + latex, + data, + lib, + ... +}: let education = data.education; - sortByStartDate = latex.sort.reverse.byFun + sortByStartDate = + latex.sort.reverse.byFun (x: with x.date.start; day + 100 * month + 10000 * year); in { title = "Education"; @@ -10,12 +14,15 @@ in { content = with latex; for (sortByStartDate education) (item: with item; - [ - (moderncv.cventry (latex.timerange date.start date.end) studyType - (with institution; href url name) institution.location "" description) - ] ++ lib.optional (item ? "years") (for (sortByStartDate years) (year: - with year; - moderncv.cvlistitem "${with program; bold (href url acronym)} (${ - timerange date.start date.end - }). ${program.studyType}. {\\small ${description}}"))); + [ + (moderncv.cventry (latex.timerange date.start date.end) studyType + (with institution; href url name) + institution.location "" + description) + ] + ++ lib.optional (item ? "years") (for (sortByStartDate years) (year: + with year; + moderncv.cvlistitem "${with program; bold (href url acronym)} (${ + timerange date.start date.end + }). ${program.studyType}. {\\small ${description}}"))); } diff --git a/src/experience/default.nix b/src/experience/default.nix index 500fd9e..a095d3d 100644 --- a/src/experience/default.nix +++ b/src/experience/default.nix @@ -1,6 +1,10 @@ -{ latex, data, lib, ... }: - -let experience = data.experience; +{ + latex, + data, + lib, + ... +}: let + experience = data.experience; in { title = "Experience"; priority = 0; @@ -8,14 +12,19 @@ in { for (sort.reverse.byFun (x: with x.date.start; day + 100 * month + 10000 * year) experience) (item: - with item; + with item; moderncv.cventry (latex.timerange date.start date.end) institution.position (with institution; href url name) - institution.location (if item ? supervisors then - "supervised by " + lib.concatStringsSep " \\& " - (for supervisors (supervisor: with supervisor; href url name)) - else - "") (description + lib.optionalString (item ? assets) (" " + cite + institution.location ( + if item ? supervisors + then + "supervised by " + + lib.concatStringsSep " \\& " + (for supervisors (supervisor: with supervisor; href url name)) + else "" + ) (description + + lib.optionalString (item ? assets) (" " + + cite (lib.concatStringsSep "," (for (lib.filter (asset: asset.type == "Publications") assets) (lib.getAttr "id")))))); diff --git a/src/languages/default.nix b/src/languages/default.nix index d030818..9853c32 100644 --- a/src/languages/default.nix +++ b/src/languages/default.nix @@ -1,12 +1,16 @@ -{ latex, data, lib, ... }: - -let +{ + latex, + data, + lib, + ... +}: let languages = data.languages; - sortByProficiency = lib.sort (lang1: lang2: - let - prof1 = lang1.proficiency; - prof2 = lang2.proficiency; - in (prof2 == "basic") || (prof1 == "native") + sortByProficiency = lib.sort (lang1: lang2: let + prof1 = lang1.proficiency; + prof2 = lang2.proficiency; + in + (prof2 == "basic") + || (prof1 == "native") || (prof2 == "intermediate" && prof1 == "fluent")); in { title = "Languages"; @@ -18,5 +22,5 @@ in { content = with latex; for (sortByProficiency languages) (lang: with lang; - moderncv.cvline "${name} \\emoji{${icon.shortcode}}" proficiency); + moderncv.cvline "${name} \\emoji{${icon.shortcode}}" proficiency); } diff --git a/src/publications/default.nix b/src/publications/default.nix index 1d6232e..bc081c7 100644 --- a/src/publications/default.nix +++ b/src/publications/default.nix @@ -1,10 +1,12 @@ -{ latex, data, lib, ... }: - -let +{ + latex, + data, + ... +}: let publications = data.publications; publicationsBIB = builtins.toFile "publications.bib" (latex.lines (builtins.map (entry: entry.cite.biblatex) - (latex.sort.reverse.byPath [ "issued" "date-parts" ] publications))); + (latex.sort.reverse.byPath ["issued" "date-parts"] publications))); in { title = "Publications"; priority = 30; diff --git a/src/sections.nix b/src/sections.nix index faed484..2778beb 100644 --- a/src/sections.nix +++ b/src/sections.nix @@ -1,15 +1,21 @@ -{ latex, make, ... }: - -let +{ + latex, + make, + ... +}: let sectionTemplate = section: { inherit (section) title priority; - extraHeader = if section ? extraHeader then section.extraHeader else ""; + extraHeader = + if section ? extraHeader + then section.extraHeader + else ""; content = latex.section section.title section.content; }; - makeSection = path: sectionTemplate (make path { }); -in builtins.map makeSection [ - ./experience - ./education - ./languages - ./publications -] + makeSection = path: sectionTemplate (make path {}); +in + builtins.map makeSection [ + ./experience + ./education + ./languages + ./publications + ] |
