summaryrefslogtreecommitdiff
path: root/default.nix
blob: cd092f9e033e29d28f47a3e509636568fa3697e1 (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
{
  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-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-emoji}/share/fonts/noto fonts
    '') {};

  latexDeps = tl: {
    inherit
      (tl)
      scheme-basic
      biber
      biblatex
      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"
    '') {};
}