# Stolen from: https://gist.github.com/jjwatt/c83c02e6903c8ffaf546fe5eb27e7d25?permalink_comment_id=3305141#gistcomment-3305141
{ pkgs, ... }:
pkgs.stdenv.mkDerivation rec {
  name = "fennel-ls";
  src = pkgs.fetchgit {
    url = "https://git.sr.ht/~xerool/fennel-ls";
    rev = "70e434839fdf9fad7512118d3f72e38aa8d3ca9f";
    sha256 = "mYOAlSCixlWzykPeLcGyTzWksDAJjblkYwI0k1GuYvE=";
  };
  buildInputs = with pkgs; [
    lua
    fennel
  ];

  configurePhase = ''
    echo [DIRECTORY] $(pwd)
    sed  -i 's/\.\/fennel/fennel/' Makefile
    # cd build/
    # cmake ..
  '';

  buildPhase = ''
    make -j4
  '';

  installPhase = ''
    mkdir -p $out/bin
    chmod a+x fennel-ls
    cp -v fennel-ls $out/bin
  '';
}
