1{ lib
2, stdenv
3, fetchFromGitLab
4, fetchpatch
5, autoreconfHook
6, libmd
7, gitUpdater
8}:
9
10# Run `./get-version` for the new value when bumping the Git revision.
11let gitVersion = "0.11.7-55-g73b2"; in
12
13stdenv.mkDerivation {
14 pname = "libbsd";
15 version = "unstable-2023-04-29";
16
17 src = fetchFromGitLab {
18 domain = "gitlab.freedesktop.org";
19 owner = "libbsd";
20 repo = "libbsd";
21 rev = "73b25a8f871b3a20f6ff76679358540f95d7dbfd";
22 hash = "sha256-LS28taIMjRCl6xqg75eYOIrTDl8PzSa+OvrdiEOP1+U=";
23 };
24
25 outputs = [ "out" "dev" "man" ];
26
27 enableParallelBuilding = true;
28
29 doCheck = true;
30
31 nativeBuildInputs = [ autoreconfHook ];
32 propagatedBuildInputs = [ libmd ];
33
34 patches = [
35 # Fix `{get,set}progname(3bsd)` conditionalization
36 # https://gitlab.freedesktop.org/libbsd/libbsd/-/issues/24
37 (fetchpatch {
38 url = "https://github.com/emilazy/libbsd/commit/0381f8d92873c5a19ced3ff861ee8ffe7825953e.patch";
39 hash = "sha256-+RMg5eHLgC4gyX9zXM0ttNf7rd9E3UzJX/7UVCYGXx4=";
40 })
41 ] ++ lib.optionals stdenv.isDarwin [
42 # Temporary build system hack from upstream maintainer
43 # https://gitlab.freedesktop.org/libbsd/libbsd/-/issues/19#note_2017684
44 ./darwin-fix-libbsd.sym.patch
45 ];
46
47 postPatch = ''
48 substituteInPlace configure.ac \
49 --replace 'm4_esyscmd([./get-version])' '[${gitVersion}]'
50 '';
51
52 passthru.updateScript = gitUpdater {
53 # No nicer place to find latest release.
54 url = "https://gitlab.freedesktop.org/libbsd/libbsd.git";
55 };
56
57 meta = with lib; {
58 description = "Common functions found on BSD systems";
59 homepage = "https://libbsd.freedesktop.org/";
60 license = with licenses; [ beerware bsd2 bsd3 bsdOriginal isc mit ];
61 platforms = platforms.unix;
62 maintainers = with maintainers; [ matthewbauer ];
63 };
64}