summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/op/openvi/package.nix
blob: f2689ab608245b837515ca12b59aa912a19505ce (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  pkg-config,
  ncurses,
  perl,
  fetchpatch,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "openvi";
  version = "7.7.32";

  src = fetchFromGitHub {
    owner = "johnsonjh";
    repo = "OpenVi";
    tag = finalAttrs.version;
    hash = "sha256-kLULaKEefMpNLANnVdWAZeH+2KY5gEWGce6vJ/R7HAI=";
  };

  patches = [
    # fix build w/ glibc 2.42 (https://github.com/johnsonjh/OpenVi/pull/46)
    (fetchpatch {
      url = "https://github.com/johnsonjh/OpenVi/commit/67c76961f512bfe95616fe25b32928db0aab9326.patch";
      hash = "sha256-GOair/unxROEPvtTekGuKacKwOctPyoRdvilqdVLjrY=";
      excludes = [ "ChangeLog" ];
    })
  ];

  nativeBuildInputs = [ pkg-config ];

  buildInputs = [
    perl
  ]
  ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
    ncurses
  ];

  makeFlags = [
    "PREFIX=$(out)"
    # command -p will yield command not found error
    "PAWK=awk"
    # silently fail the chown command
    "IUSGR=$(USER)"
  ];

  # Don't include ncurses header, but link against ncurses
  # openvi requires GNU ncurses symbols, but ncurses headers
  # is incompatible with macOS wchar.h, resulting in
  # "error: expected function body after function declarator"
  env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-L${lib.getLib ncurses}/lib -lncursesw";

  enableParallelBuilding = true;

  meta = {
    homepage = "https://github.com/johnsonjh/OpenVi";
    description = "Portable OpenBSD vi for UNIX systems";
    license = lib.licenses.bsd3;
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ aleksana ];
    mainProgram = "ovi";
  };
})