This repository has been archived on 2024-05-23. You can view files and clone it, but cannot push or open issues or pull requests.
katex-html/default.nix

32 lines
765 B
Nix
Raw Normal View History

2022-03-27 18:28:20 -07:00
{ bundlerEnv, ruby, stdenv, katex-server }:
let
2022-03-27 17:52:41 -07:00
gems = bundlerEnv {
inherit ruby;
name = "render-test";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
};
in
stdenv.mkDerivation {
2022-03-27 18:29:38 -07:00
name = "katex-html";
src = ./convert.rb;
2022-03-27 18:28:20 -07:00
buildInputs = [ katex-server gems ruby ];
unpackPhase = "echo 'Skipping unpack phase (nothing to unpack)'";
installPhase = ''
2022-03-27 18:29:38 -07:00
mkdir -p $out/{bin,share/katex-html}
cp $src $out/share/katex-html/convert.rb
cat > $out/bin/katex-html <<EOF
#!/bin/sh -e
2022-03-27 18:28:20 -07:00
${katex-server}/bin/katex-server &
server_pid=\$!
sleep 1
2022-03-27 18:29:38 -07:00
${gems}/bin/bundle exec ${ruby}/bin/ruby $out/share/katex-html/convert.rb \$@
2022-03-27 18:28:20 -07:00
kill -KILL \$server_pid
EOF
2022-03-27 18:29:38 -07:00
chmod +x $out/bin/katex-html
'';
}