1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 autoreconfHook,
6 nix-update-script,
7 fetchpatch,
8 ncurses ? null,
9
10 # Enable `termcap` (`ncurses`) support.
11 enableTermcap ? false,
12}:
13
14assert lib.assertMsg (
15 enableTermcap -> ncurses != null
16) "`ncurses` must be provided when `enableTermcap` is enabled";
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "editline";
20 version = "1.17.1";
21 src = fetchFromGitHub {
22 owner = "troglobit";
23 repo = "editline";
24 rev = finalAttrs.version;
25 sha256 = "sha256-0FeDUVCUahbweH24nfaZwa7j7lSfZh1TnQK7KYqO+3g=";
26 };
27
28 patches = [
29 (fetchpatch {
30 name = "fix-for-home-end-in-tmux.patch";
31 url = "https://github.com/troglobit/editline/commit/265c1fb6a0b99bedb157dc7c320f2c9629136518.patch";
32 sha256 = "sha256-9fhQH0hT8BcykGzOUoT18HBtWjjoXnePSGDJQp8GH30=";
33 })
34
35 # Pending autoconf-2.72 upstream support:
36 # https://github.com/troglobit/editline/pull/64
37 (fetchpatch {
38 name = "autoconf-2.72.patch";
39 url = "https://github.com/troglobit/editline/commit/f444a316f5178b8e20fe31e7b2d979e651da077e.patch";
40 hash = "sha256-m3jExTkPvE+ZBwHzf/A+ugzzfbLmeWYn726l7Po7f10=";
41 })
42
43 # Recognize `Alt-Left` and `Alt-Right` for navigating by words in more
44 # terminals/shells/platforms.
45 #
46 # See: https://github.com/troglobit/editline/pull/70
47 (fetchpatch {
48 name = "alt-left-alt-right-word-navigation.patch";
49 url = "https://github.com/troglobit/editline/commit/fb4d7268de024ed31ad2417f533cc0cbc2cd9b29.diff";
50 hash = "sha256-5zMsmpU5zFoffRUwFhI/vP57pEhGotcMPgn9AfI1SNg=";
51 })
52 ];
53
54 configureFlags = [
55 # Enable SIGSTOP (Ctrl-Z) behavior.
56 (lib.enableFeature true "sigstop")
57 # Enable ANSI arrow keys.
58 (lib.enableFeature true "arrow-keys")
59 # Use termcap library to query terminal size.
60 (lib.enableFeature enableTermcap "termcap")
61 ];
62
63 nativeBuildInputs = [ autoreconfHook ];
64
65 propagatedBuildInputs = lib.optional enableTermcap ncurses;
66
67 outputs = [
68 "out"
69 "dev"
70 "man"
71 "doc"
72 ];
73
74 passthru.updateScript = nix-update-script { };
75
76 meta = with lib; {
77 homepage = "https://troglobit.com/projects/editline/";
78 description = "Readline() replacement for UNIX without termcap (ncurses)";
79 license = licenses.bsdOriginal;
80 maintainers = with maintainers; [ oxalica ];
81 platforms = platforms.all;
82 };
83})