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