about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/json-glib
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/json-glib')
-rw-r--r--nixpkgs/pkgs/development/libraries/json-glib/default.nix106
-rw-r--r--nixpkgs/pkgs/development/libraries/json-glib/meson-add-installed-tests-prefix-option.patch27
2 files changed, 133 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/json-glib/default.nix b/nixpkgs/pkgs/development/libraries/json-glib/default.nix
new file mode 100644
index 000000000000..0ca03efca025
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/json-glib/default.nix
@@ -0,0 +1,106 @@
+{ lib
+, stdenv
+, fetchurl
+, glib
+, meson
+, ninja
+, nixosTests
+, pkg-config
+, gettext
+, withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
+, buildPackages
+, gobject-introspection
+, gi-docgen
+, libxslt
+, fixDarwinDylibNames
+, gnome
+}:
+
+stdenv.mkDerivation rec {
+  pname = "json-glib";
+  version = "1.6.6";
+
+  outputs = [ "out" "dev" "installedTests" ]
+    ++ lib.optional withIntrospection "devdoc";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "luyYvnqR9t3jNjZyDj2i/27LuQ52zKpJSX8xpoVaSQ4=";
+  };
+
+  patches = [
+    # Add option for changing installation path of installed tests.
+    ./meson-add-installed-tests-prefix-option.patch
+  ];
+
+  strictDeps = true;
+
+  depsBuildBuild = [
+    pkg-config
+  ];
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkg-config
+    gettext
+    glib
+    libxslt
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
+    fixDarwinDylibNames
+  ] ++ lib.optionals withIntrospection [
+    gobject-introspection
+    gi-docgen
+  ];
+
+  propagatedBuildInputs = [
+    glib
+  ];
+
+  mesonFlags = [
+    "-Dinstalled_test_prefix=${placeholder "installedTests"}"
+    (lib.mesonEnable "introspection" withIntrospection)
+    (lib.mesonEnable "gtk_doc" withIntrospection)
+  ];
+
+  # Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
+  # it should be a build-time dep for build
+  # TODO: send upstream
+  postPatch = ''
+    substituteInPlace doc/meson.build \
+      --replace "'gi-docgen', ver" "'gi-docgen', native:true, ver" \
+      --replace "'gi-docgen', req" "'gi-docgen', native:true, req"
+  '';
+
+  doCheck = true;
+
+  postFixup = ''
+    # Move developer documentation to devdoc output.
+    # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
+    if [[ -d "$out/share/doc" ]]; then
+        find -L "$out/share/doc" -type f -regex '.*\.devhelp2?' -print0 \
+          | while IFS= read -r -d ''' file; do
+            moveToOutput "$(dirname "''${file/"$out/"/}")" "$devdoc"
+        done
+    fi
+  '';
+
+  passthru = {
+    tests = {
+      installedTests = nixosTests.installed-tests.json-glib;
+    };
+
+    updateScript = gnome.updateScript {
+      packageName = pname;
+      versionPolicy = "odd-unstable";
+    };
+  };
+
+  meta = with lib; {
+    description = "A library providing (de)serialization support for the JavaScript Object Notation (JSON) format";
+    homepage = "https://wiki.gnome.org/Projects/JsonGlib";
+    license = licenses.lgpl21Plus;
+    maintainers = teams.gnome.members;
+    platforms = with platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/json-glib/meson-add-installed-tests-prefix-option.patch b/nixpkgs/pkgs/development/libraries/json-glib/meson-add-installed-tests-prefix-option.patch
new file mode 100644
index 000000000000..626db09cd03f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/json-glib/meson-add-installed-tests-prefix-option.patch
@@ -0,0 +1,27 @@
+diff --git a/json-glib/tests/meson.build b/json-glib/tests/meson.build
+index 1eb56c8..dca444e 100644
+--- a/json-glib/tests/meson.build
++++ b/json-glib/tests/meson.build
+@@ -21,8 +21,9 @@ test_data = [
+   'stream-load.json',
+ ]
+ 
+-installed_test_bindir = join_paths(json_libexecdir, 'installed-tests', json_api_name)
+-installed_test_datadir = join_paths(json_datadir, 'installed-tests', json_api_name)
++installed_test_prefix = get_option('installed_test_prefix')
++installed_test_bindir = join_paths(installed_test_prefix, 'libexec', 'installed-tests', json_api_name)
++installed_test_datadir = join_paths(installed_test_prefix, 'share', 'installed-tests', json_api_name)
+ 
+ install_data(test_data, install_dir: installed_test_bindir)
+ 
+diff --git a/meson_options.txt b/meson_options.txt
+index 068a03f..03f398a 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -10,3 +10,6 @@ option('man',
+ option('tests',
+        type: 'boolean', value: true,
+        description: 'Build the tests')
++option('installed_test_prefix',
++       description: 'Prefix for installed tests',
++       type: 'string')