1{ lib, stdenv
2, fetchFromGitLab
3, meson
4, ninja
5, pkg-config
6, gobject-introspection
7, wrapGAppsNoGuiHook
8, glib
9, coreutils
10, accountsservice
11, dbus
12, pam
13, polkit
14, glib-testing
15, python3
16, nixosTests
17}:
18
19stdenv.mkDerivation rec {
20 pname = "malcontent";
21 version = "0.12.0";
22
23 outputs = [ "bin" "out" "lib" "pam" "dev" "man" "installedTests" ];
24
25 src = fetchFromGitLab {
26 domain = "gitlab.freedesktop.org";
27 owner = "pwithnall";
28 repo = "malcontent";
29 rev = version;
30 hash = "sha256-UK/WVqDMkwIqkTFFjzh7PRCA/Ej8Iyu33FasnAEApRs=";
31 };
32
33 patches = [
34 # Allow installing installed tests to a separate output.
35 ./installed-tests-path.patch
36
37 # Do not build things that are part of malcontent-ui package
38 ./better-separation.patch
39 ];
40
41 nativeBuildInputs = [
42 meson
43 ninja
44 pkg-config
45 gobject-introspection
46 wrapGAppsNoGuiHook
47 ];
48
49 buildInputs = [
50 accountsservice
51 dbus
52 pam
53 polkit
54 glib-testing
55 (python3.withPackages (pp: with pp; [
56 pygobject3
57 ]))
58 ];
59
60 propagatedBuildInputs = [
61 glib
62 ];
63
64 mesonFlags = [
65 "-Dinstalled_tests=true"
66 "-Dinstalled_test_prefix=${placeholder "installedTests"}"
67 "-Dpamlibdir=${placeholder "pam"}/lib/security"
68 "-Dui=disabled"
69 ];
70
71 postPatch = ''
72 substituteInPlace libmalcontent/tests/app-filter.c \
73 --replace "/usr/bin/true" "${coreutils}/bin/true" \
74 --replace "/bin/true" "${coreutils}/bin/true" \
75 --replace "/usr/bin/false" "${coreutils}/bin/false" \
76 --replace "/bin/false" "${coreutils}/bin/false"
77 '';
78
79 postInstall = ''
80 # `giDiscoverSelf` only picks up paths in `out` output.
81 # This needs to be in `postInstall` so that it runs before
82 # `gappsWrapperArgsHook` that runs as one of `preFixupPhases`.
83 addToSearchPath GI_TYPELIB_PATH "$lib/lib/girepository-1.0"
84 '';
85
86 passthru = {
87 tests = {
88 installedTests = nixosTests.installed-tests.malcontent;
89 };
90 };
91
92 meta = with lib; {
93 # We need to install Polkit & AccountsService data files in `out`
94 # but `buildEnv` only uses `bin` when both `bin` and `out` are present.
95 outputsToInstall = [ "bin" "out" "man" ];
96
97 description = "Parental controls library";
98 mainProgram = "malcontent-client";
99 homepage = "https://gitlab.freedesktop.org/pwithnall/malcontent";
100 license = licenses.lgpl21Plus;
101 maintainers = with maintainers; [ jtojnar ];
102 platforms = platforms.unix;
103 };
104}