1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 autoreconfHook,
7 flex,
8}:
9
10stdenv.mkDerivation rec {
11 pname = "libconfuse";
12 version = "3.3";
13
14 src = fetchFromGitHub {
15 sha256 = "1npfk5jv59kk4n8pkyx89fn9s6p8x3gbffs42jaw24frgxfgp8ca";
16 rev = "v${version}";
17 repo = "libconfuse";
18 owner = "martinh";
19 };
20
21 patches = [
22 (fetchpatch {
23 name = "CVE-2022-40320.patch";
24 urls = [
25 "https://sources.debian.org/data/main/libc/libconfuse/3.3-3/debian/patches/CVE-2022-40320.patch"
26 # files on sources.debian.org can disappear
27 "https://web.archive.org/web/20230107133212/https://sources.debian.org/data/main/libc/libconfuse/3.3-3/debian/patches/CVE-2022-40320.patch"
28 ];
29 sha256 = "sha256-ftfE9JFz4nyRSOb2xHb9BAtgWn5Yv2WLm4RegDLtiBw=";
30 })
31 ];
32
33 postPatch = ''
34 substituteInPlace tests/Makefile.am \
35 --replace 'TESTS += empty_string' "" \
36 --replace 'TESTS += print_filter' ""
37 '';
38
39 nativeBuildInputs = [
40 autoreconfHook
41 flex
42 ];
43
44 enableParallelBuilding = true;
45
46 # On darwin the tests depend on the installed libraries because of install_name.
47 doInstallCheck = true;
48 installCheckTarget = "check";
49
50 meta = with lib; {
51 inherit (src.meta) homepage;
52 description = "Small configuration file parser library for C";
53 longDescription = ''
54 libConfuse (previously libcfg) is a configuration file parser library
55 written in C. It supports sections and (lists of) values, as well as
56 some other features. It makes it very easy to add configuration file
57 capability to a program using a simple API.
58
59 The goal of libConfuse is not to be the configuration file parser library
60 with a gazillion of features. Instead, it aims to be easy to use and
61 quick to integrate with your code.
62 '';
63 license = licenses.isc;
64 platforms = platforms.linux ++ platforms.darwin;
65 };
66}