summaryrefslogtreecommitdiff
path: root/default.nix
blob: 6bf384fdceb798cc11a968518eff0e0bb29aca23 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  pkgs,
  latex,
  data,
}:
let
  commonArgs = {
    inherit data latex make;
    inherit (pkgs) lib;
  };
  make =
    path: overrides:
    let
      f = import path;
    in
    f ((builtins.intersectAttrs (builtins.functionArgs f) commonArgs) // overrides);

  cvTEX = builtins.toFile "cv.tex" (make ./src { });
  source = pkgs.callPackage (
    {
      noto-fonts-color-emoji,
      # Source files
      cv-tex ? cvTEX,
      files ? data.files,
    }:
    pkgs.runCommand "cv-src" { } ''
      mkdir -p "$out" && cd $_
      ln -sT ${cv-tex} cv.tex
      ln -sT ${files} files
      ln -sT ${noto-fonts-color-emoji}/share/fonts/noto fonts
    ''
  ) { };

  latexDeps = tl: {
    inherit (tl)
      scheme-basic
      citation-style-language
      latexmk
      luatex
      luatexbase
      moderncv
      fontspec
      fontawesome5
      academicons
      pgf
      multirow
      arydshln
      emoji
      ;
  };
in
{
  inherit latexDeps;

  src = source;
  pdf = pkgs.callPackage (
    {
      cv-src ? source,
      texlive,
    }:
    pkgs.runCommand "cv.pdf"
      {
        buildInputs = [ (texlive.combine (latexDeps texlive)) ];
      }
      ''
        export HOME=$(pwd)
        latexmk -pdflua -cd "${cv-src}"/cv.tex --output-directory=$(pwd)
        mv cv.pdf "$out"
      ''
  ) { };
}