final: prev:

let
  inherit (final) lib;
in

rec {

  # https://github.com/bugaevc/wl-clipboard/issues/185
  wl-clipboard-timeout = prev.symlinkJoin {
    inherit (prev.wl-clipboard) name;
    paths = [
      (prev.writeShellScriptBin "wl-copy" ''
        timeout 0.3s ${lib.getExe' prev.wl-clipboard "wl-copy"} "$@"
      '')
      (prev.writeShellScriptBin "wl-paste" ''
        timeout 0.3s ${lib.getExe' prev.wl-clipboard "wl-paste"} "$@"
      '')
      prev.wl-clipboard
    ];
  };

  micro = if prev.micro.override.__functionArgs ? wl-clipboard
    then prev.micro.override {
        wl-clipboard = wl-clipboard-timeout;
      }
    else prev.micro;
}
