{ stdenv, makeWrapper, haskellngPackages }:

let
  #redo = haskellPackages.callPackage ./redo.nix {};
  redo = stdenv.lib.overrideDerivation (haskellngPackages.redo) (attrs: {
    patches = attrs.patches ++ [./redo.patch];
  });
in stdenv.mkDerivation {
  name = "redo-wrapper";

  nativeBuildInputs = [ makeWrapper ];

  buildCommand = ''
    mkdir -p $out/bin
    ln -s $out/bin/redo $out/bin/redo-ifchange
    makeWrapper ${redo}/bin/redo $out/bin/redo \
      --set REDO_PATH "$out/bin"
  '';
}