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