You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
795 B
Nix

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