1{
2 lib,
3 fetchFromGitHub,
4 fetchurl,
5 buildDunePackage,
6 gen,
7 ppxlib,
8 uchar,
9 ppx_expect,
10}:
11
12let
13 param =
14 if lib.versionAtLeast ppxlib.version "0.26.0" then
15 {
16 version = "3.6";
17 sha256 = "sha256-NiNqur7sce6dxictVB+saOC1c4N/EO/3Ici/icsGkIA=";
18 }
19 else
20 {
21 version = "2.5";
22 sha256 = "sha256:062a5dvrzvb81l3a9phljrhxfw9nlb61q341q0a6xn65hll3z2wy";
23 };
24in
25
26let
27 unicodeVersion = "16.0.0";
28 baseUrl = "https://www.unicode.org/Public/${unicodeVersion}";
29
30 DerivedCoreProperties = fetchurl {
31 url = "${baseUrl}/ucd/DerivedCoreProperties.txt";
32 sha256 = "sha256-OdNRYfKVRJf2ngi9uecBST9Haj0wIi3iACj+2jbB2r0=";
33 };
34 DerivedGeneralCategory = fetchurl {
35 url = "${baseUrl}/ucd/extracted/DerivedGeneralCategory.txt";
36 sha256 = "sha256-dnardVpB74IQhGAjhWnmCtZcGR3a/mGzbGdl7BNT8pM=";
37 };
38 PropList = fetchurl {
39 url = "${baseUrl}/ucd/PropList.txt";
40 sha256 = "sha256-U9YUUI4qCyMFqKohzWDZk96TJs32WZNmDfzORQNUhYM=";
41 };
42 atLeast31 = lib.versionAtLeast param.version "3.1";
43in
44buildDunePackage rec {
45 pname = "sedlex";
46 inherit (param) version;
47
48 minimalOCamlVersion = "4.08";
49
50 src = fetchFromGitHub {
51 owner = "ocaml-community";
52 repo = "sedlex";
53 rev = "v${version}";
54 inherit (param) sha256;
55 };
56
57 propagatedBuildInputs = [
58 gen
59 ppxlib
60 ]
61 ++ lib.optionals (!atLeast31) [
62 uchar
63 ];
64
65 preBuild = ''
66 rm src/generator/data/dune
67 ln -s ${DerivedCoreProperties} src/generator/data/DerivedCoreProperties.txt
68 ln -s ${DerivedGeneralCategory} src/generator/data/DerivedGeneralCategory.txt
69 ln -s ${PropList} src/generator/data/PropList.txt
70 '';
71
72 checkInputs = lib.optionals atLeast31 [
73 ppx_expect
74 ];
75
76 doCheck = true;
77
78 dontStrip = true;
79
80 meta = {
81 homepage = "https://github.com/ocaml-community/sedlex";
82 changelog = "https://github.com/ocaml-community/sedlex/raw/v${version}/CHANGES";
83 description = "OCaml lexer generator for Unicode";
84 license = lib.licenses.mit;
85 maintainers = [ ];
86 };
87}