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