diff --git a/nixos/tests/installed-tests/default.nix b/nixos/tests/installed-tests/default.nix index 0551b235ba90..a189ef63f222 100644 --- a/nixos/tests/installed-tests/default.nix +++ b/nixos/tests/installed-tests/default.nix @@ -92,6 +92,7 @@ in libgdata = callInstalledTest ./libgdata.nix {}; glib-testing = callInstalledTest ./glib-testing.nix {}; libxmlb = callInstalledTest ./libxmlb.nix {}; + malcontent = callInstalledTest ./malcontent.nix {}; ostree = callInstalledTest ./ostree.nix {}; xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {}; } diff --git a/nixos/tests/installed-tests/malcontent.nix b/nixos/tests/installed-tests/malcontent.nix new file mode 100644 index 000000000000..d4e214c41988 --- /dev/null +++ b/nixos/tests/installed-tests/malcontent.nix @@ -0,0 +1,5 @@ +{ pkgs, makeInstalledTest, ... }: + +makeInstalledTest { + tested = pkgs.malcontent; +} 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') diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d36b0a9d03f1..c0fcbad1d0b1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12774,6 +12774,8 @@ in libmad = callPackage ../development/libraries/libmad { }; + malcontent = callPackage ../development/libraries/malcontent { }; + libmanette = callPackage ../development/libraries/libmanette { }; libmatchbox = callPackage ../development/libraries/libmatchbox { };