summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/el/eli/package.nix
blob: 8114013f1baf32036124b6c8afe028033b34bc1d (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
  lib,
  stdenv,
  fetchurl,
  symlinkJoin,
  makeWrapper,
  tcl,
  fontconfig,
  tk,
  ncurses,
  libxt,
  libxext,
  libxaw,
  libx11,
  file,
}:

let
  # eli derives the location of the include folder from the location of the lib folder
  tk_combined = symlinkJoin {
    name = "tk_combined";
    paths = [
      tk
      tk.dev
    ];
  };
  curses_combined = symlinkJoin {
    name = "curses_combined";
    paths = [
      ncurses
      ncurses.dev
    ];
  };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "eli";
  version = "4.8.1";

  src = fetchurl {
    url = "mirror://sourceforge/project/eli-project/Eli/Eli%20${finalAttrs.version}/eli-${finalAttrs.version}.tar.bz2";
    sha256 = "1vran8583hbwrr5dciji4zkhz3f88w4mn8n9sdpr6zw0plpf1whj";
  };

  patches = [
    # Newer GCC will reject function parameters with an implicit type of `int` and undefined
    # references to undeclared functions.
    ./function-declarations.patch
  ];

  buildInputs = [
    ncurses
    fontconfig
    libx11.dev
    libxt.dev
    libxaw.dev
    libxext.dev
  ];

  nativeBuildInputs = [
    file
    makeWrapper
  ];

  # skip interactive browser check
  buildFlags = [ "nobrowsers" ];

  # Workaround build failure on -fno-common toolchains:
  #   ld: cexp.o:(.bss+0x40): multiple definition of `obstck'; cccp.o:(.bss+0x0): first defined here
  # Workaround build failure on "function definitions with identifier lists":
  #   C23 throws errors on "function definitions with identifier lists". As it is pervasively used
  #   in the upstream codebase, it's impossible to fix that legacy syntax without a full treewide
  #   refactor. So the currently fix is to pin the standard to C17.
  env.NIX_CFLAGS_COMPILE = "-fcommon --std=gnu17";

  preConfigure = ''
    configureFlagsArray=(
      --with-tcltk="${tcl} ${tk_combined}"
      --with-curses="${curses_combined}"
    )
    export ODIN_LOCALIPC=1
  '';

  postInstall = ''
    wrapProgram "$out/bin/eli" \
      --set ODIN_LOCALIPC 1
  '';

  # Test if eli starts
  doInstallCheck = true;
  installCheckPhase = ''
    export HOME="$TMP/home"
    mkdir -p "$HOME"
    $out/bin/eli "!ls"
  '';

  meta = {
    description = "Translator Construction Made Easy";
    longDescription = ''
      Eli is a programming environment that supports all phases of translator
      construction with extensive libraries implementing common tasks, yet handling
      arbitrary special cases. Output is the C subset of C++.
    '';
    homepage = "https://eli-project.sourceforge.net/";
    license = lib.licenses.gpl2;
    maintainers = with lib.maintainers; [ timokau ];
    platforms = lib.platforms.linux;
  };
})