about summary refs log tree commit diff
path: root/pkgs/applications/editors/mle/default.nix
blob: e6744ac8a82e8d7df927389f2159a9e8993ae0d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, pcre
, uthash
, lua5_4
, makeWrapper
, installShellFiles
}:

stdenv.mkDerivation rec {
  pname = "mle";
  version = "1.5.0";

  src = fetchFromGitHub {
    owner = "adsr";
    repo = "mle";
    rev = "v${version}";
    sha256 = "1nhd00lsx9v12zdmps92magz76c2d8zzln3lxvzl4ng73gbvq3n0";
  };

  # Bug fixes found after v1.5.0 release
  patches = [
    (fetchpatch {
      name = "skip_locale_dep_test.patch";
      url = "https://github.com/adsr/mle/commit/e4dc4314b02a324701d9ae9873461d34cce041e5.patch";
      sha256 = "sha256-j3Z/n+2LqB9vEkWzvRVSOrF6yE+hk6f0dvEsTQ74erw=";
    })
    (fetchpatch {
      name = "fix_input_trail.patch";
      url = "https://github.com/adsr/mle/commit/bc05ec0eee4143d824010c6688fce526550ed508.patch";
      sha256 = "sha256-dM63EBDQfHLAqGZk3C5NtNAv23nCTxXVW8XpLkAeEyQ=";
    })
  ];

  # Fix location of Lua 5.4 header and library
  postPatch = ''
    substituteInPlace Makefile --replace "-llua5.4" "-llua";
    substituteInPlace mle.h    --replace "<lua5.4/" "<";
    patchShebangs tests/*
  '';

  # Use select(2) instead of poll(2) (poll is returning POLLINVAL on macOS)
  # Enable compiler optimization
  CFLAGS = "-DTB_OPT_SELECT -O2";

  nativeBuildInputs = [ makeWrapper installShellFiles ];

  buildInputs = [ pcre uthash lua5_4 ];

  doCheck = true;

  installFlags = [ "prefix=${placeholder "out"}" ];

  postInstall = ''
    installManPage mle.1
  '';

  meta = with lib; {
    description = "Small, flexible, terminal-based text editor";
    homepage = "https://github.com/adsr/mle";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ adsr ];
  };
}