about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/text/rosie/default.nix
blob: 190fd4944d15e37b57b10e5f3bd81d9f077c6613 (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
{ lib
, stdenv
, fetchgit
, libbsd
, readline
}:

stdenv.mkDerivation rec {
  pname = "rosie";
  version = "1.3.0";

  src = fetchgit {
    url = "https://gitlab.com/rosie-pattern-language/rosie";
    rev = "9303e04ae2cffabdda6ccc4e2a351a47218615ff";
    sha256 = "1smh760baf43hr56p6rh4khz3shyzda5lqva4ffxwchl7yy7r82j";
    fetchSubmodules = true;
  };

  postUnpack = ''
    # The Makefile calls git to update submodules, unless this file exists
    touch ${src.name}/submodules/~~present~~
  '';

  preConfigure = ''
    patchShebangs src/build_info.sh
    # rosie is ran as part of `make check`,
    # and so needs to be patched in preConfigure.
    patchShebangs rosie
    # Part of the same Makefile target which calls git to update submodules
    ln -s src submodules/lua/include
    # ldconfig is irrelevant, disable it inside `make installforce`.
    sed -iE 's/ldconfig/echo skippin ldconfig/' Makefile
    sed -iE '/ld.so.conf.d/d' Makefile
  '';

  preInstall = lib.optionalString stdenv.isDarwin ''
    install_name_tool -add_rpath $out/lib build/bin/rosie
    install_name_tool -id $out/lib/librosie.dylib build/lib/librosie.dylib
  '';

  postInstall = ''
    mkdir -p $out/share/emacs/site-lisp $out/share/vim-plugins $out/share/nvim
    mv $out/lib/rosie/extra/emacs/* $out/share/emacs/site-lisp/
    mv $out/lib/rosie/extra/vim $out/share/vim-plugins/rosie
    ln -s $out/share/vim-plugins/rosie $out/share/nvim/site
  '';

  # librosie.so is dlopen'ed , so we disable ELF patching to preserve RUNPATH .
  dontPatchELF = true;

  makeFlags = [ "DESTDIR=${placeholder "out"}" ];

  buildInputs = [ libbsd readline ];

  meta = with lib; {
    homepage = "https://rosie-lang.org";
    description = "Tools for searching using parsing expression grammars";
    license = licenses.mit;
    maintainers = with maintainers; [ kovirobi ];
    platforms = with platforms; linux ++ darwin;
  };
}