1{
2 stdenv,
3 lib,
4 fetchgit,
5 cmake,
6 pkg-config,
7 json_c,
8 with_lua ? false,
9 lua5_1,
10 with_ustream_ssl ? false,
11 ustream-ssl,
12}:
13
14stdenv.mkDerivation {
15 pname = "libubox";
16 version = "0-unstable-2024-12-19";
17
18 src = fetchgit {
19 url = "https://git.openwrt.org/project/libubox.git";
20 rev = "3868f47c8f6c6570e62a3cdf8a7f26ffb1a67e6a";
21 hash = "sha256-rACcvyMhksw5A+Tkn6XiTqz1DHK23YKRHL7j3CEccr4=";
22 };
23
24 cmakeFlags = [
25 "-DBUILD_EXAMPLES=OFF"
26 (if with_lua then "-DLUAPATH=${placeholder "out"}/lib/lua" else "-DBUILD_LUA=OFF")
27 ];
28
29 nativeBuildInputs = [
30 cmake
31 pkg-config
32 ];
33 buildInputs = [
34 json_c
35 ]
36 ++ lib.optional with_lua lua5_1
37 ++ lib.optional with_ustream_ssl ustream-ssl;
38
39 postInstall = lib.optionalString with_ustream_ssl ''
40 for fin in $(find ${ustream-ssl} -type f); do
41 fout="''${fin/"${ustream-ssl}"/"''${out}"}"
42 ln -s "$fin" "$fout"
43 done
44 '';
45
46 env.NIX_CFLAGS_COMPILE = toString (
47 lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
48 "-Wno-error=gnu-folding-constant"
49 ]
50 );
51
52 meta = with lib; {
53 description = "C utility functions for OpenWrt";
54 homepage = "https://git.openwrt.org/?p=project/libubox.git;a=summary";
55 license = licenses.isc;
56 maintainers = with maintainers; [
57 fpletz
58 mkg20001
59 ];
60 mainProgram = "jshn";
61 platforms = platforms.all;
62 };
63}