btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / libdbusmenu / package.nix
blob5143372d2b0db73ef522ec56633044b9570dcbc6
1 { stdenv, fetchurl, lib, file
2 , pkg-config, intltool
3 , glib, dbus-glib, json-glib
4 , gobject-introspection, vala
5 , gtkVersion ? null, gtk2, gtk3
6 , testers
7 }:
9 stdenv.mkDerivation (finalAttrs: {
10   pname = "libdbusmenu-${if gtkVersion == null then "glib" else "gtk${gtkVersion}"}";
11   version = "16.04.0";
13   src = let
14     inherit (finalAttrs) version;
15   in fetchurl {
16     url = "https://launchpad.net/dbusmenu/${lib.versions.majorMinor version}/${version}/+download/libdbusmenu-${version}.tar.gz";
17     sha256 = "12l7z8dhl917iy9h02sxmpclnhkdjryn08r8i4sr8l3lrlm4mk5r";
18   };
20   nativeBuildInputs = [ vala pkg-config intltool gobject-introspection ];
22   buildInputs = [
23     glib dbus-glib json-glib
24   ] ++ lib.optional (gtkVersion != null)
25     {
26       "2" = gtk2;
27       "3" = gtk3;
28     }.${gtkVersion} or (throw "unknown GTK version ${gtkVersion}");
30   patches = [
31     ./requires-glib.patch
32   ];
34   postPatch = ''
35     for f in {configure,ltmain.sh,m4/libtool.m4}; do
36       substituteInPlace $f \
37         --replace /usr/bin/file ${file}/bin/file
38     done
39   '';
41   # https://projects.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/libdbusmenu
42   preConfigure = ''
43     export HAVE_VALGRIND_TRUE="#"
44     export HAVE_VALGRIND_FALSE=""
45   '';
47   configureFlags = [
48     "CFLAGS=-Wno-error"
49     "--sysconfdir=/etc"
50     "--localstatedir=/var"
51     # TODO use `lib.withFeatureAs`
52     (if gtkVersion == null then "--disable-gtk" else "--with-gtk=${gtkVersion}")
53     "--disable-scrollkeeper"
54   ] ++ lib.optional (gtkVersion != "2") "--disable-dumper";
56   doCheck = false; # generates shebangs in check phase, too lazy to fix
58   installFlags = [
59     "sysconfdir=${placeholder "out"}/etc"
60     "localstatedir=\${TMPDIR}"
61     "typelibdir=${placeholder "out"}/lib/girepository-1.0"
62   ];
64   passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
66   meta = with lib; {
67     description = "Library for passing menu structures across DBus";
68     homepage = "https://launchpad.net/dbusmenu";
69     license = with licenses; [ gpl3 lgpl21 lgpl3 ];
70     pkgConfigModules = [
71       "dbusmenu-glib-0.4"
72       "dbusmenu-jsonloader-0.4"
73     ] ++ lib.optional (gtkVersion == "3") "dbusmenu-gtk${gtkVersion}-0.4";
74     platforms = platforms.linux;
75     maintainers = [ maintainers.msteen ];
76   };