btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / js / json-glib / package.nix
blobe3db856c23cdb8b4aab79760204235b425eade3a
1 { lib
2 , stdenv
3 , fetchurl
4 , fetchpatch
5 , docutils
6 , glib
7 , meson
8 , mesonEmulatorHook
9 , ninja
10 , nixosTests
11 , pkg-config
12 , gettext
13 , withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
14 , buildPackages
15 , gobject-introspection
16 , gi-docgen
17 , libxslt
18 , fixDarwinDylibNames
19 , gnome
22 stdenv.mkDerivation rec {
23   pname = "json-glib";
24   version = "1.10.0";
26   outputs = [ "out" "dev" "installedTests" ]
27     ++ lib.optional withIntrospection "devdoc";
29   src = fetchurl {
30     url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
31     sha256 = "G8qNZtlhBuzBR98xM7laW7eE8fpvFdBt18Go+0oQr3s=";
32   };
34   patches = [
35     # Add option for changing installation path of installed tests.
36     ./meson-add-installed-tests-prefix-option.patch
38     # Restore single quote string extension
39     # https://gitlab.gnome.org/GNOME/json-glib/-/issues/76
40     (fetchpatch {
41       url = "https://gitlab.gnome.org/GNOME/json-glib/-/commit/2a26bd3dedc3b27471e6df210d76333d3d41159c.patch";
42       hash = "sha256-U/jWB4wneN4MwZO3vAfI9Z7UT/SLMNEx/X8NMsCO8I4=";
43     })
44   ];
46   strictDeps = true;
48   depsBuildBuild = [
49     pkg-config
50   ];
52   nativeBuildInputs = [
53     docutils # for rst2man, rst2html5
54     meson
55     ninja
56     pkg-config
57     gettext
58     glib
59     libxslt
60   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
61     fixDarwinDylibNames
62   ] ++ lib.optionals withIntrospection [
63     gobject-introspection
64     gi-docgen
65   ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
66     mesonEmulatorHook
67   ];
69   propagatedBuildInputs = [
70     glib
71   ];
73   mesonFlags = [
74     "-Dinstalled_test_prefix=${placeholder "installedTests"}"
75     (lib.mesonEnable "introspection" withIntrospection)
76     (lib.mesonEnable "documentation" withIntrospection)
77   ];
79   doCheck = true;
81   postFixup = ''
82     # Move developer documentation to devdoc output.
83     # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
84     if [[ -d "$out/share/doc" ]]; then
85         find -L "$out/share/doc" -type f -regex '.*\.devhelp2?' -print0 \
86           | while IFS= read -r -d ''' file; do
87             moveToOutput "$(dirname "''${file/"$out/"/}")" "$devdoc"
88         done
89     fi
90   '';
92   passthru = {
93     tests = {
94       installedTests = nixosTests.installed-tests.json-glib;
95     };
97     updateScript = gnome.updateScript {
98       packageName = pname;
99       versionPolicy = "odd-unstable";
100     };
101   };
103   meta = with lib; {
104     description = "Library providing (de)serialization support for the JavaScript Object Notation (JSON) format";
105     homepage = "https://gitlab.gnome.org/GNOME/json-glib";
106     license = licenses.lgpl21Plus;
107     maintainers = teams.gnome.members;
108     platforms = with platforms; unix;
109   };