nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, fetchFromGitHub
3, fetchurl
4, buildDunePackage
5, ocaml
6, gen
7, ppxlib
8, uchar
9}:
10
11if lib.versionOlder ocaml.version "4.08"
12then throw "sedlex is not available for OCaml ${ocaml.version}"
13else
14
15let
16 unicodeVersion = "13.0.0";
17 baseUrl = "https://www.unicode.org/Public/${unicodeVersion}";
18
19 DerivedCoreProperties = fetchurl {
20 url = "${baseUrl}/ucd/DerivedCoreProperties.txt";
21 sha256 = "0j12x112cd8fpgazkc8izxnhhpia44p1m36ff8yapslxndcmzm55";
22 };
23 DerivedGeneralCategory = fetchurl {
24 url = "${baseUrl}/ucd/extracted/DerivedGeneralCategory.txt";
25 sha256 = "0w6mkz4w79k23bnmwgfxc4yqc2ypv8ilrjn6nk25hrafksbg00j5";
26 };
27 PropList = fetchurl {
28 url = "${baseUrl}/ucd/PropList.txt";
29 sha256 = "1ks0585wimygbk2wqi9hqg8gyl25iffvdad5vya1zgsxs8z5lns8";
30 };
31in
32buildDunePackage rec {
33 pname = "sedlex";
34 version = "2.4";
35
36 useDune2 = true;
37
38 src = fetchFromGitHub {
39 owner = "ocaml-community";
40 repo = "sedlex";
41 rev = "v${version}";
42 sha256 = "13g8az4zqg6hrnxmy3qrasslppzlag13dd1dsr8vlpg2vpfmfv6i";
43 };
44
45 propagatedBuildInputs = [
46 gen uchar ppxlib
47 ];
48
49 preBuild = ''
50 rm src/generator/data/dune
51 ln -s ${DerivedCoreProperties} src/generator/data/DerivedCoreProperties.txt
52 ln -s ${DerivedGeneralCategory} src/generator/data/DerivedGeneralCategory.txt
53 ln -s ${PropList} src/generator/data/PropList.txt
54 '';
55
56 doCheck = true;
57
58 dontStrip = true;
59
60 meta = {
61 homepage = "https://github.com/ocaml-community/sedlex";
62 changelog = "https://github.com/ocaml-community/sedlex/raw/v${version}/CHANGES";
63 description = "An OCaml lexer generator for Unicode";
64 license = lib.licenses.mit;
65 maintainers = [ lib.maintainers.marsam ];
66 };
67}