nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.7";
17 sha256 = "sha256-ucqrJkzS6cVogGUf1vU8oBpSryneMBqTjzxwsOi6Egs=";
18 }
19 else
20 {
21 version = "2.5";
22 sha256 = "sha256:062a5dvrzvb81l3a9phljrhxfw9nlb61q341q0a6xn65hll3z2wy";
23 };
24in
25
26let
27 unicodeVersion = "17.0.0";
28 baseUrl = "https://www.unicode.org/Public/${unicodeVersion}";
29
30 DerivedCoreProperties = fetchurl {
31 url = "${baseUrl}/ucd/DerivedCoreProperties.txt";
32 hash = "sha256-JMf+0RlcSC+q79XB5+uCHF7h+23gfs26pktWqZ2iLAg=";
33 };
34 DerivedGeneralCategory = fetchurl {
35 url = "${baseUrl}/ucd/extracted/DerivedGeneralCategory.txt";
36 hash = "sha256-1i5bq3DKdPCZND9xIk+gUcsf3WGhq0XASIxEz8C2EC4=";
37 };
38 PropList = fetchurl {
39 url = "${baseUrl}/ucd/PropList.txt";
40 hash = "sha256-Ew3N3Kra8HEAi9/OHndD4E/fvJEIhvAX2fmskx2MZN0=";
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}