about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/libraries/malcontent/default.nix87
-rw-r--r--pkgs/development/libraries/malcontent/installed-tests-path.patch35
-rw-r--r--pkgs/development/libraries/malcontent/use-system-dependencies.patch22
3 files changed, 144 insertions, 0 deletions
diff --git a/pkgs/development/libraries/malcontent/default.nix b/pkgs/development/libraries/malcontent/default.nix
new file mode 100644
index 000000000000..3a40be3c4edb
--- /dev/null
+++ b/pkgs/development/libraries/malcontent/default.nix
@@ -0,0 +1,87 @@
+{ stdenv
+, fetchFromGitLab
+, meson
+, ninja
+, pkgconfig
+, gobject-introspection
+, wrapGAppsHook
+, glib
+, coreutils
+, dbus
+, polkit
+, glib-testing
+, python3
+, nixosTests
+}:
+
+stdenv.mkDerivation rec {
+  pname = "malcontent";
+  version = "0.4.0";
+
+  outputs = [ "bin" "out" "dev" "man" "installedTests" ];
+
+  src = fetchFromGitLab {
+    domain = "gitlab.freedesktop.org";
+    owner = "pwithnall";
+    repo = pname;
+    rev = version;
+    sha256 = "0d703r20djvrgy711jvn90i8dwbb0p7qj4j43z101afpkiizq810";
+  };
+
+  patches = [
+    # Allow installing installed tests to a separate output.
+    ./installed-tests-path.patch
+
+    # This is unnecessary and breaks when submodules are not available.
+    # https://gitlab.freedesktop.org/pwithnall/malcontent/merge_requests/3
+    ./use-system-dependencies.patch
+  ];
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkgconfig
+    gobject-introspection
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    dbus
+    polkit
+    glib-testing
+    (python3.withPackages (pp: with pp; [
+      pygobject3
+    ]))
+  ];
+
+  propagatedBuildInputs = [
+    glib
+  ];
+
+  mesonFlags = [
+    "-Dinstalled_tests=true"
+    "-Dinstalled_test_prefix=${placeholder "installedTests"}"
+  ];
+
+  postPatch = ''
+    substituteInPlace libmalcontent/tests/app-filter.c \
+      --replace "/usr/bin/true" "${coreutils}/bin/true" \
+      --replace "/bin/true" "${coreutils}/bin/true" \
+      --replace "/usr/bin/false" "${coreutils}/bin/false" \
+      --replace "/bin/false" "${coreutils}/bin/false"
+  '';
+
+  passthru = {
+    tests = {
+      installedTests = nixosTests.installed-tests.malcontent;
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "Parental controls library";
+    homepage = "https://gitlab.freedesktop.org/pwithnall/malcontent";
+    license = licenses.lgpl21Plus;
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/malcontent/installed-tests-path.patch b/pkgs/development/libraries/malcontent/installed-tests-path.patch
new file mode 100644
index 000000000000..f2e75c2a8546
--- /dev/null
+++ b/pkgs/development/libraries/malcontent/installed-tests-path.patch
@@ -0,0 +1,35 @@
+diff --git a/libmalcontent/tests/meson.build b/libmalcontent/tests/meson.build
+index a8a815a..0b1d242 100644
+--- a/libmalcontent/tests/meson.build
++++ b/libmalcontent/tests/meson.build
+@@ -61,9 +61,9 @@ test_programs = [
+   ], deps],
+ ]
+ 
+-installed_tests_metadir = join_paths(datadir, 'installed-tests',
++installed_tests_metadir = join_paths(get_option('installed_test_prefix'), 'share', 'installed-tests',
+                                      'libmalcontent-' + libmalcontent_api_version)
+-installed_tests_execdir = join_paths(libexecdir, 'installed-tests',
++installed_tests_execdir = join_paths(get_option('installed_test_prefix'), 'libexec', 'installed-tests',
+                                      'libmalcontent-' + libmalcontent_api_version)
+ 
+ foreach program: test_programs
+@@ -94,4 +94,4 @@ foreach program: test_programs
+     env: envs,
+     args: ['--tap'],
+   )
+-endforeach
+\ No newline at end of file
++endforeach
+diff --git a/meson_options.txt b/meson_options.txt
+index 96a517d..7cb1ee8 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -3,4 +3,5 @@ option(
+   type: 'boolean',
+   value: false,
+   description: 'enable installed tests'
+-)
+\ No newline at end of file
++)
++option('installed_test_prefix', type: 'string', value: '', description: 'Prefix for installed tests')
diff --git a/pkgs/development/libraries/malcontent/use-system-dependencies.patch b/pkgs/development/libraries/malcontent/use-system-dependencies.patch
new file mode 100644
index 000000000000..315bfe5ec109
--- /dev/null
+++ b/pkgs/development/libraries/malcontent/use-system-dependencies.patch
@@ -0,0 +1,22 @@
+diff --git a/meson.build b/meson.build
+index f4a05ba..dd31537 100644
+--- a/meson.build
++++ b/meson.build
+@@ -33,9 +33,8 @@ polkit_gobject = dependency('polkit-gobject-1')
+ polkitpolicydir = polkit_gobject.get_pkgconfig_variable('policydir',
+   define_variable: ['prefix', prefix])
+ 
+-libglib_testing = subproject('libglib-testing')
+ libglib_testing_dep = dependency(
+-  'libglib-testing',
++  'glib-testing-0',
+   fallback: ['libglib-testing', 'libglib_testing_dep'],
+ )
+ 
+@@ -120,4 +119,4 @@ test_env = [
+ 
+ subdir('accounts-service')
+ subdir('malcontent-client')
+-subdir('libmalcontent')
+\ No newline at end of file
++subdir('libmalcontent')