at 23.11-beta 85 lines 2.1 kB view raw
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 { 15 version = "3.2"; 16 sha256 = "sha256-5Vf1LRhSotNpTPzHmRgCMRYtrpgaspLlyzv1XdGt+u8="; 17 } 18 else { 19 version = "2.5"; 20 sha256 = "sha256:062a5dvrzvb81l3a9phljrhxfw9nlb61q341q0a6xn65hll3z2wy"; 21 } 22; in 23 24let 25 unicodeVersion = "15.0.0"; 26 baseUrl = "https://www.unicode.org/Public/${unicodeVersion}"; 27 28 DerivedCoreProperties = fetchurl { 29 url = "${baseUrl}/ucd/DerivedCoreProperties.txt"; 30 sha256 = "sha256-02cpC8CGfmtITGg3BTC90aCLazJARgG4x6zK+D4FYo0="; 31 }; 32 DerivedGeneralCategory = fetchurl { 33 url = "${baseUrl}/ucd/extracted/DerivedGeneralCategory.txt"; 34 sha256 = "sha256-/imkXAiCUA5ZEUCqpcT1Bn5qXXRoBhSK80QAxIucBvk="; 35 }; 36 PropList = fetchurl { 37 url = "${baseUrl}/ucd/PropList.txt"; 38 sha256 = "sha256-4FwKKBHRE9rkq9gyiEGZo+qNGH7huHLYJAp4ipZUC/0="; 39 }; 40 atLeast31 = lib.versionAtLeast param.version "3.1"; 41in 42buildDunePackage rec { 43 pname = "sedlex"; 44 inherit (param) version; 45 46 minimalOCamlVersion = "4.08"; 47 duneVersion = "3"; 48 49 src = fetchFromGitHub { 50 owner = "ocaml-community"; 51 repo = "sedlex"; 52 rev = "v${version}"; 53 inherit (param) sha256; 54 }; 55 56 propagatedBuildInputs = [ 57 gen 58 ppxlib 59 ] ++ lib.optionals (!atLeast31) [ 60 uchar 61 ]; 62 63 preBuild = '' 64 rm src/generator/data/dune 65 ln -s ${DerivedCoreProperties} src/generator/data/DerivedCoreProperties.txt 66 ln -s ${DerivedGeneralCategory} src/generator/data/DerivedGeneralCategory.txt 67 ln -s ${PropList} src/generator/data/PropList.txt 68 ''; 69 70 checkInputs = lib.optionals atLeast31 [ 71 ppx_expect 72 ]; 73 74 doCheck = true; 75 76 dontStrip = true; 77 78 meta = { 79 homepage = "https://github.com/ocaml-community/sedlex"; 80 changelog = "https://github.com/ocaml-community/sedlex/raw/v${version}/CHANGES"; 81 description = "An OCaml lexer generator for Unicode"; 82 license = lib.licenses.mit; 83 maintainers = [ lib.maintainers.marsam ]; 84 }; 85}