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 ] ++ lib.optional with_lua lua5_1 ++ lib.optional with_ustream_ssl ustream-ssl;
35
36 postInstall = lib.optionalString with_ustream_ssl ''
37 for fin in $(find ${ustream-ssl} -type f); do
38 fout="''${fin/"${ustream-ssl}"/"''${out}"}"
39 ln -s "$fin" "$fout"
40 done
41 '';
42
43 env.NIX_CFLAGS_COMPILE = toString (
44 lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
45 "-Wno-error=gnu-folding-constant"
46 ]
47 );
48
49 meta = with lib; {
50 description = "C utility functions for OpenWrt";
51 homepage = "https://git.openwrt.org/?p=project/libubox.git;a=summary";
52 license = licenses.isc;
53 maintainers = with maintainers; [
54 fpletz
55 mkg20001
56 ];
57 mainProgram = "jshn";
58 platforms = platforms.all;
59 };
60}