btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / libgweather / package.nix
blobc528a2198ddcc73bddc2dac70501284d28643460
1 { lib
2 , stdenv
3 , buildPackages
4 , fetchurl
5 , makeWrapper
6 , meson
7 , ninja
8 , pkg-config
9 , libxml2
10 , json-glib
11 , glib
12 , gettext
13 , libsoup_3
14 , gi-docgen
15 , gobject-introspection
16 , python3
17 , tzdata
18 , geocode-glib_2
19 , vala
20 , gnome
21 , withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
24 stdenv.mkDerivation rec {
25   pname = "libgweather";
26   version = "4.4.4";
28   outputs = [ "out" "dev" ] ++ lib.optional withIntrospection "devdoc";
30   src = fetchurl {
31     url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
32     hash = "sha256-cBdnd1PN99H9w1Xkv82x66g2l5Oo3yTSQUJ6k5y/QoM=";
33   };
35   patches = [
36     # Headers depend on glib but it is only listed in Requires.private,
37     # which does not influence Cflags on non-static builds in nixpkgs’s
38     # pkg-config. Let’s add it to Requires to ensure Cflags are set correctly.
39     ./fix-pkgconfig.patch
40   ];
42   depsBuildBuild = [
43     makeWrapper
44     pkg-config
45   ];
47   nativeBuildInputs = [
48     meson
49     ninja
50     pkg-config
51     gettext
52     glib
53     (python3.pythonOnBuildForHost.withPackages (ps: [ ps.pygobject3 ]))
54   ] ++ lib.optionals withIntrospection [
55     gi-docgen
56     gobject-introspection
57     vala
58   ];
60   buildInputs = [
61     glib
62     libsoup_3
63     libxml2
64     json-glib
65     geocode-glib_2
66   ];
68   mesonFlags = [
69     "-Dzoneinfo_dir=${tzdata}/share/zoneinfo"
70     (lib.mesonBool "introspection" withIntrospection)
71   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
72     "-Dc_args=-D_DARWIN_C_SOURCE"
73   ];
75   postPatch = ''
76     patchShebangs --build build-aux/meson/gen_locations_variant.py
77     wrapProgram $PWD/build-aux/meson/gen_locations_variant.py \
78       --prefix GI_TYPELIB_PATH : ${lib.getLib buildPackages.glib}/lib/girepository-1.0 \
80     # Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
81     # it should be a build-time dep for build
82     # TODO: send upstream
83     substituteInPlace doc/meson.build \
84       --replace-fail "'gi-docgen', ver" "'gi-docgen', native:true, ver" \
85       --replace-fail "'gi-docgen', req" "'gi-docgen', native:true, req"
87     # gir works for us even when cross-compiling
88     # TODO: send upstream because downstream users can use the option to disable gir if they don't have it working
89     substituteInPlace meson.build \
90       --replace-fail "g_ir_scanner.found() and not meson.is_cross_build()" "g_ir_scanner.found()"
92     substituteInPlace libgweather/meson.build --replace-fail \
93       "dependency('vapigen', required: enable_vala == 'true')" \
94       "dependency('vapigen', native: true, required: enable_vala == 'true')"
95   '';
97   postFixup = ''
98     # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
99     moveToOutput "share/doc" "$devdoc"
100   '';
102   strictDeps = true;
104   passthru = {
105     updateScript = gnome.updateScript {
106       packageName = pname;
107       versionPolicy = "odd-unstable";
108       # Version 40.alpha preceded version 4.0.
109       freeze = "40.alpha";
110     };
111   };
113   meta = with lib; {
114     description = "Library to access weather information from online services for numerous locations";
115     homepage = "https://gitlab.gnome.org/GNOME/libgweather";
116     license = licenses.gpl2Plus;
117     maintainers = teams.gnome.members;
118     platforms = platforms.unix;
119   };