1{
2 lib,
3 stdenv,
4 meson,
5 ninja,
6 fetchFromGitLab,
7 re2c,
8 gperf,
9 gawk,
10 pkg-config,
11 boost,
12 fmt,
13 luajit_openresty,
14 ncurses,
15 serd,
16 sord,
17 libcap,
18 liburing,
19 openssl,
20 cereal,
21 cmake,
22 asciidoctor,
23 makeWrapper,
24 versionCheckHook,
25 gitUpdater,
26 enableIoUring ? false,
27 emilua, # this package
28}:
29
30stdenv.mkDerivation (finalAttrs: {
31 pname = "emilua";
32 version = "0.11.7";
33
34 src = fetchFromGitLab {
35 owner = "emilua";
36 repo = "emilua";
37 tag = "v${finalAttrs.version}";
38 hash = "sha256-c+X8HD/G75XD54Fs89DSkebLDd7h12Bk45+w7VBUXPY=";
39 };
40
41 propagatedBuildInputs = [
42 luajit_openresty
43 boost
44 fmt
45 ncurses
46 serd
47 sord
48 libcap
49 liburing
50 openssl
51 cereal
52 ];
53
54 nativeBuildInputs = [
55 re2c
56 gperf
57 gawk
58 pkg-config
59 asciidoctor
60 meson
61 cmake
62 ninja
63 makeWrapper
64 ];
65
66 dontUseCmakeConfigure = true;
67
68 mesonFlags = [
69 (lib.mesonBool "enable_io_uring" enableIoUring)
70 (lib.mesonBool "enable_file_io" enableIoUring)
71 (lib.mesonBool "enable_tests" true)
72 (lib.mesonBool "enable_manpages" true)
73 (lib.mesonOption "version_suffix" "-nixpkgs1")
74 ];
75
76 postPatch = ''
77 patchShebangs src/emilua_gperf.awk --interpreter '${lib.getExe gawk} -f'
78 '';
79
80 # io_uring is not allowed in Nix sandbox, that breaks the tests
81 doCheck = !enableIoUring;
82
83 mesonCheckFlags = [
84 # Skipped test: libpsx
85 # Known issue with no-new-privs disabled in the Nix build environment.
86 "--no-suite"
87 "libpsx"
88 ];
89
90 postInstall = ''
91 mkdir -p $out/nix-support
92 cp ${./setup-hook.sh} $out/nix-support/setup-hook
93 substituteInPlace $out/nix-support/setup-hook \
94 --replace-fail @sitePackages@ "${finalAttrs.passthru.sitePackages}"
95 '';
96
97 nativeInstallCheckInputs = [
98 versionCheckHook
99 ];
100 versionCheckProgramArg = "--version";
101 doInstallCheck = true;
102
103 passthru = {
104 updateScript = gitUpdater { rev-prefix = "v"; };
105 inherit boost;
106 sitePackages = "lib/emilua-${(lib.concatStringsSep "." (lib.take 2 (lib.splitVersion finalAttrs.version)))}";
107 tests.with-io-uring = emilua.override { enableIoUring = true; };
108 };
109
110 meta = {
111 description = "Lua execution engine";
112 mainProgram = "emilua";
113 homepage = "https://emilua.org/";
114 license = lib.licenses.boost;
115 maintainers = with lib.maintainers; [
116 manipuladordedados
117 lucasew
118 ];
119 platforms = lib.platforms.linux;
120 };
121})