···1+{ lib
2+, stdenv
3+, fetchurl
4+, ncurses
5+}:
6+7+stdenv.mkDerivation (finalAttrs: {
8+ pname = "libedit";
9+ version = "20230828-3.1";
10+11+ src = fetchurl {
12+ url = "https://thrysoee.dk/editline/libedit-${finalAttrs.version}.tar.gz";
13+ hash = "sha256-TugYK25WkpDn0fRPD3jayHFrNfZWt2Uo9pnGnJiBTa0=";
14+ };
15+16+ outputs = [ "out" "dev" "man" ];
17+18+ patches = [
19+ ./01-cygwin.patch
20+ ];
21+22+ propagatedBuildInputs = [
23+ ncurses
24+ ];
25+26+ # GCC automatically include `stdc-predefs.h` while Clang does not do this by
27+ # default. While Musl is ISO 10646 compliant, it does not define
28+ # __STDC_ISO_10646__.
29+ # This definition is in `stdc-predefs.h` -- that's why libedit builds just
30+ # fine with GCC and Musl.
31+ # There is a DR to fix this issue with Clang which is not merged yet.
32+ # https://reviews.llvm.org/D137043
33+ env.NIX_CFLAGS_COMPILE =
34+ lib.optionalString (stdenv.targetPlatform.isMusl && stdenv.cc.isClang)
35+ "-D__STDC_ISO_10646__=201103L";
36+37+ postFixup = ''
38+ find $out/lib -type f | \
39+ grep '\.\(la\|pc\)''$' | \
40+ xargs sed -i -e 's,-lncurses[a-z]*,-L${ncurses.out}/lib -lncursesw,g'
41+ '';
42+43+ meta = {
44+ homepage = "http://www.thrysoee.dk/editline/";
45+ description = "A port of the NetBSD Editline library (libedit)";
46+ longDescription = ''
47+ This is an autotool- and libtoolized port of the NetBSD Editline library
48+ (libedit). This Berkeley-style licensed command line editor library
49+ provides generic line editing, history, and tokenization functions,
50+ similar to those found in GNU Readline.
51+ '';
52+ license = with lib.licenses; [ bsd3 ];
53+ maintainers = with lib.maintainers; [ AndersonTorres ];
54+ platforms = lib.platforms.all;
55+ };
56+})