-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
74 lines (66 loc) · 1.89 KB
/
flake.nix
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
72
73
74
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
utils,
...
}:
utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
scripts = {
build-resume = pkgs.writeShellApplication {
name = "build-resume";
runtimeInputs = with pkgs; [
nodePackages.prettier
wkhtmltopdf
];
text = ''
shopt -s globstar
for x in resume/*.md; do
fname="$(basename "$x")"
template_path="resume/''${fname%.*}.template.html"
css_path="resume/''${fname%.*}.css"
cp resume/*.css public/
# Plaintext
pandoc "$x" -t plain -o "public/''${fname%.*}.txt"
template () {
if [[ -f $template_path ]]; then
echo "--template" "$template_path"
else
echo "--template" "resume/template.html"
fi
}
css () {
if [[ -f $css_path ]]; then
echo " --css" "$css_path"
fi
}
# HTML
eval "pandoc $x -t html $(template)" | prettier --stdin-filepath foo.html > "public/''${fname%.*}.html"
# PDF
eval "pandoc $x -t html $(template)$(css) -o public/''${fname%.*}.pdf"
done
'';
};
};
in
{
devShell = pkgs.mkShell {
buildInputs =
with pkgs;
[
yarn
pandoc
]
++ builtins.map (x: x.value) (lib.attrsToList scripts);
};
packages = scripts;
}
);
}