···11+{ lib
22+, stdenv
33+, fetchurl
44+, ncurses
55+}:
66+77+stdenv.mkDerivation (finalAttrs: {
88+ pname = "libedit";
99+ version = "20230828-3.1";
1010+1111+ src = fetchurl {
1212+ url = "https://thrysoee.dk/editline/libedit-${finalAttrs.version}.tar.gz";
1313+ hash = "sha256-TugYK25WkpDn0fRPD3jayHFrNfZWt2Uo9pnGnJiBTa0=";
1414+ };
1515+1616+ outputs = [ "out" "dev" "man" ];
1717+1818+ patches = [
1919+ ./01-cygwin.patch
2020+ ];
2121+2222+ propagatedBuildInputs = [
2323+ ncurses
2424+ ];
2525+2626+ # GCC automatically include `stdc-predefs.h` while Clang does not do this by
2727+ # default. While Musl is ISO 10646 compliant, it does not define
2828+ # __STDC_ISO_10646__.
2929+ # This definition is in `stdc-predefs.h` -- that's why libedit builds just
3030+ # fine with GCC and Musl.
3131+ # There is a DR to fix this issue with Clang which is not merged yet.
3232+ # https://reviews.llvm.org/D137043
3333+ env.NIX_CFLAGS_COMPILE =
3434+ lib.optionalString (stdenv.targetPlatform.isMusl && stdenv.cc.isClang)
3535+ "-D__STDC_ISO_10646__=201103L";
3636+3737+ postFixup = ''
3838+ find $out/lib -type f | \
3939+ grep '\.\(la\|pc\)''$' | \
4040+ xargs sed -i -e 's,-lncurses[a-z]*,-L${ncurses.out}/lib -lncursesw,g'
4141+ '';
4242+4343+ meta = {
4444+ homepage = "http://www.thrysoee.dk/editline/";
4545+ description = "A port of the NetBSD Editline library (libedit)";
4646+ longDescription = ''
4747+ This is an autotool- and libtoolized port of the NetBSD Editline library
4848+ (libedit). This Berkeley-style licensed command line editor library
4949+ provides generic line editing, history, and tokenization functions,
5050+ similar to those found in GNU Readline.
5151+ '';
5252+ license = with lib.licenses; [ bsd3 ];
5353+ maintainers = with lib.maintainers; [ AndersonTorres ];
5454+ platforms = lib.platforms.all;
5555+ };
5656+})