-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
84 lines (76 loc) · 2.05 KB
/
shell.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
75
76
77
78
79
80
81
82
83
84
{}:
let
sources = import ./nix/sources.nix;
nixpkgs = sources.nixpkgs;
pkgs = import nixpkgs { };
revealjs = pkgs.callPackage ./nix/revealjs.nix { };
# reveal.js 3.7.0 has minified version, needed for self-contained
# -V revealjs-url=https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.7.0 \
revealjs_37 = pkgs.callPackage ./nix/revealjs_37.nix { };
linkRevealJs = pkgs.writeShellScriptBin "linkrevealjs" ''
${pkgs.coreutils}/bin/ln -sf ${revealjs}/reveal.js .
'';
mkSlides = pkgs.writeShellScriptBin "mkslides" ''
REVEAL=${revealjs}/reveal.js
SLIDE_LEVEL="1"
OUTPUT="index.html"
INPUT="slides.md"
while getopts ":h:nt:so:l:i:" opt; do
case "''${opt}" in
h)
HIGHLIGHT_STYLE="--highlight-style=''${OPTARG}"
;;
n)
HIGHLIGHT_STYLE="--no-highlight"
CUSTOM_TEMPLATE="''${CUSTOM_TEMPLATE:-custom.revealjs}"
;;
t)
CUSTOM_TEMPLATE="''${OPTARG}"
;;
s)
SELF_CONTAINED="--self-contained"
REVEAL="${revealjs_37}/reveal.js"
;;
o)
OUTPUT="''${OPTARG}"
;;
l)
SLIDE_LEVEL="''${OPTARG}"
;;
i)
INPUT="''${OPTARG}"
;;
\? )
echo "Usage: mkslides"
;;
esac
done
if [[ -n "''${CUSTOM_TEMPLATE}" ]];
then
TEMPLATE="--template=''${CUSTOM_TEMPLATE}"
fi
PANDOC_ARGS=(
"-t revealjs"
"-V revealjs-url=$REVEAL"
"''${SELF_CONTAINED:-}"
"''${HIGHLIGHT_STYLE:-}"
"''${TEMPLATE:-}"
"--slide-level=$SLIDE_LEVEL"
"--standalone"
"--output $OUTPUT"
"$INPUT"
)
echo ''${PANDOC_ARGS[@]}
${pkgs.pandoc}/bin/pandoc ''${PANDOC_ARGS[@]}
'';
in
pkgs.stdenv.mkDerivation {
name = "presentations-shell";
buildInputs = [ pkgs.pandoc revealjs mkSlides linkRevealJs ];
NIX_PATH = "nixpkgs=${sources.nixpkgs.url}";
shellHook = ''
export LANG=en_US.UTF-8
eval "$( ${pkgs.pandoc}/bin/pandoc --bash-completion )"
echo "Welcome!"
'';
}