2021-10-30 05:39:01 +00:00
|
|
|
|
{ lib
|
|
|
|
|
, stdenv
|
2021-10-30 11:28:44 +00:00
|
|
|
|
, fetchFromGitLab
|
2021-10-30 05:39:01 +00:00
|
|
|
|
, pkg-config
|
|
|
|
|
, glib
|
|
|
|
|
, expat
|
|
|
|
|
, pam
|
2021-10-30 11:28:44 +00:00
|
|
|
|
, meson
|
2022-07-07 18:34:37 +00:00
|
|
|
|
, mesonEmulatorHook
|
2021-10-30 11:28:44 +00:00
|
|
|
|
, ninja
|
2021-10-30 05:39:01 +00:00
|
|
|
|
, perl
|
2021-10-30 11:28:44 +00:00
|
|
|
|
, rsync
|
|
|
|
|
, python3
|
2021-10-30 05:39:01 +00:00
|
|
|
|
, fetchpatch
|
2021-10-30 05:45:28 +00:00
|
|
|
|
, gettext
|
2022-07-12 20:09:30 +00:00
|
|
|
|
, duktape
|
2021-10-30 05:39:01 +00:00
|
|
|
|
, gobject-introspection
|
|
|
|
|
, libxslt
|
|
|
|
|
, docbook-xsl-nons
|
|
|
|
|
, dbus
|
|
|
|
|
, docbook_xml_dtd_412
|
|
|
|
|
, gtk-doc
|
|
|
|
|
, coreutils
|
2022-09-21 07:04:52 +00:00
|
|
|
|
, useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal
|
2022-07-03 21:11:08 +00:00
|
|
|
|
, systemdMinimal
|
2021-10-30 05:39:01 +00:00
|
|
|
|
, elogind
|
2023-03-01 17:03:30 +00:00
|
|
|
|
, buildPackages
|
2023-10-12 13:13:57 +00:00
|
|
|
|
, withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
|
2019-10-26 15:53:52 +00:00
|
|
|
|
# A few tests currently fail on musl (polkitunixusertest, polkitunixgrouptest, polkitidentitytest segfault).
|
|
|
|
|
# Not yet investigated; it may be due to the "Make netgroup support optional"
|
|
|
|
|
# patch not updating the tests correctly yet, or doing something wrong,
|
|
|
|
|
# or being unrelated to that.
|
|
|
|
|
, doCheck ? (stdenv.isLinux && !stdenv.hostPlatform.isMusl)
|
2017-05-25 16:05:46 +00:00
|
|
|
|
}:
|
2009-08-13 07:55:11 +00:00
|
|
|
|
|
2010-05-15 09:55:31 +00:00
|
|
|
|
let
|
2018-07-06 20:41:41 +00:00
|
|
|
|
system = "/run/current-system/sw";
|
2019-10-05 11:10:11 +00:00
|
|
|
|
setuid = "/run/wrappers/bin";
|
2010-05-15 09:55:31 +00:00
|
|
|
|
in
|
2009-08-13 07:55:11 +00:00
|
|
|
|
stdenv.mkDerivation rec {
|
2019-04-26 19:42:52 +00:00
|
|
|
|
pname = "polkit";
|
2023-09-12 07:19:08 +00:00
|
|
|
|
version = "123";
|
2010-05-15 09:55:31 +00:00
|
|
|
|
|
2021-10-30 05:39:01 +00:00
|
|
|
|
outputs = [ "bin" "dev" "out" ]; # small man pages in $bin
|
|
|
|
|
|
2021-10-30 11:28:44 +00:00
|
|
|
|
# Tarballs do not contain subprojects.
|
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
|
domain = "gitlab.freedesktop.org";
|
|
|
|
|
owner = "polkit";
|
|
|
|
|
repo = "polkit";
|
|
|
|
|
rev = version;
|
2023-09-12 07:19:08 +00:00
|
|
|
|
hash = "sha256-/kjWkh6w2FYgtYWzw3g3GlWJKKpkJ3cqwfE0iDqJctw=";
|
2009-08-13 07:55:11 +00:00
|
|
|
|
};
|
2010-05-15 09:55:31 +00:00
|
|
|
|
|
2021-11-01 13:51:12 +00:00
|
|
|
|
patches = [
|
|
|
|
|
# Allow changing base for paths in pkg-config file as before.
|
|
|
|
|
# https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/100
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://gitlab.freedesktop.org/polkit/polkit/-/commit/7ba07551dfcd4ef9a87b8f0d9eb8b91fabcb41b3.patch";
|
2021-11-01 13:53:13 +00:00
|
|
|
|
sha256 = "ebbLILncq1hAZTBMsLm+vDGw6j0iQ0crGyhzyLZQgKA=";
|
2021-11-01 13:51:12 +00:00
|
|
|
|
})
|
2019-09-16 03:28:12 +00:00
|
|
|
|
];
|
|
|
|
|
|
2022-07-07 18:34:37 +00:00
|
|
|
|
depsBuildBuild = [
|
|
|
|
|
pkg-config
|
|
|
|
|
];
|
|
|
|
|
|
2021-10-30 05:39:01 +00:00
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
glib
|
|
|
|
|
pkg-config
|
2021-10-30 05:45:28 +00:00
|
|
|
|
gettext
|
2021-10-30 11:28:44 +00:00
|
|
|
|
meson
|
|
|
|
|
ninja
|
2021-10-30 05:39:01 +00:00
|
|
|
|
perl
|
2021-10-30 11:28:44 +00:00
|
|
|
|
rsync
|
2021-10-30 05:39:01 +00:00
|
|
|
|
|
|
|
|
|
# man pages
|
|
|
|
|
libxslt
|
|
|
|
|
docbook-xsl-nons
|
|
|
|
|
docbook_xml_dtd_412
|
2023-03-01 17:03:30 +00:00
|
|
|
|
] ++ lib.optionals withIntrospection [
|
|
|
|
|
gobject-introspection
|
|
|
|
|
gtk-doc
|
|
|
|
|
] ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
|
2022-07-07 18:34:37 +00:00
|
|
|
|
mesonEmulatorHook
|
2021-10-30 05:39:01 +00:00
|
|
|
|
];
|
2015-10-14 04:03:25 +00:00
|
|
|
|
|
2021-10-30 05:39:01 +00:00
|
|
|
|
buildInputs = [
|
|
|
|
|
expat
|
|
|
|
|
pam
|
2022-07-07 18:34:37 +00:00
|
|
|
|
dbus
|
2022-07-12 20:09:30 +00:00
|
|
|
|
duktape
|
2021-10-30 05:39:01 +00:00
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2019-11-20 21:55:54 +00:00
|
|
|
|
# On Linux, fall back to elogind when systemd support is off.
|
2022-07-03 21:11:08 +00:00
|
|
|
|
(if useSystemd then systemdMinimal else elogind)
|
2021-10-30 05:39:01 +00:00
|
|
|
|
];
|
2009-08-13 07:55:11 +00:00
|
|
|
|
|
2019-10-05 11:08:51 +00:00
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
|
glib # in .pc Requires
|
|
|
|
|
];
|
|
|
|
|
|
2023-01-21 12:00:00 +00:00
|
|
|
|
nativeCheckInputs = [
|
2021-10-30 05:39:01 +00:00
|
|
|
|
dbus
|
2023-03-01 17:04:14 +00:00
|
|
|
|
(python3.pythonForBuild.withPackages (pp: with pp; [
|
|
|
|
|
dbus-python
|
|
|
|
|
(python-dbusmock.overridePythonAttrs (attrs: {
|
|
|
|
|
# Avoid dependency cycle.
|
|
|
|
|
doCheck = false;
|
|
|
|
|
}))
|
|
|
|
|
]))
|
2021-10-30 05:39:01 +00:00
|
|
|
|
];
|
2013-11-09 15:29:18 +00:00
|
|
|
|
|
2021-10-30 11:28:44 +00:00
|
|
|
|
mesonFlags = [
|
2018-07-06 20:41:41 +00:00
|
|
|
|
"--datadir=${system}/share"
|
|
|
|
|
"--sysconfdir=/etc"
|
2022-10-26 21:19:24 +00:00
|
|
|
|
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
|
2021-10-30 11:28:44 +00:00
|
|
|
|
"-Dpolkitd_user=polkituser" #TODO? <nixos> config.ids.uids.polkituser
|
|
|
|
|
"-Dos_type=redhat" # only affects PAM includes
|
2023-03-01 17:03:30 +00:00
|
|
|
|
"-Dintrospection=${lib.boolToString withIntrospection}"
|
2021-10-30 11:28:44 +00:00
|
|
|
|
"-Dtests=${lib.boolToString doCheck}"
|
2023-03-01 17:03:30 +00:00
|
|
|
|
"-Dgtk_doc=${lib.boolToString withIntrospection}"
|
2021-10-30 11:28:44 +00:00
|
|
|
|
"-Dman=true"
|
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
|
"-Dsession_tracking=${if useSystemd then "libsystemd-login" else "libelogind"}"
|
2021-10-30 05:39:01 +00:00
|
|
|
|
];
|
2011-08-22 11:45:51 +00:00
|
|
|
|
|
2021-10-30 11:28:44 +00:00
|
|
|
|
# HACK: We want to install policy files files to $out/share but polkit
|
|
|
|
|
# should read them from /run/current-system/sw/share on a NixOS system.
|
|
|
|
|
# Similarly for config files in /etc.
|
|
|
|
|
# With autotools, it was possible to override Make variables
|
|
|
|
|
# at install time but Meson does not support this
|
|
|
|
|
# so we need to convince it to install all files to a temporary
|
|
|
|
|
# location using DESTDIR and then move it to proper one in postInstall.
|
|
|
|
|
DESTDIR = "${placeholder "out"}/dest";
|
2018-07-06 20:41:41 +00:00
|
|
|
|
|
2018-06-16 02:57:44 +00:00
|
|
|
|
inherit doCheck;
|
2021-10-30 05:39:01 +00:00
|
|
|
|
|
2021-10-30 11:28:44 +00:00
|
|
|
|
postPatch = ''
|
|
|
|
|
patchShebangs test/polkitbackend/polkitbackendjsauthoritytest-wrapper.py
|
2021-10-30 05:39:01 +00:00
|
|
|
|
|
|
|
|
|
# ‘libpolkit-agent-1.so’ should call the setuid wrapper on
|
|
|
|
|
# NixOS. Hard-coding the path is kinda ugly. Maybe we can just
|
|
|
|
|
# call through $PATH, but that might have security implications.
|
|
|
|
|
substituteInPlace src/polkitagent/polkitagentsession.c \
|
|
|
|
|
--replace 'PACKAGE_PREFIX "/lib/polkit-1/' '"${setuid}/'
|
|
|
|
|
substituteInPlace test/data/etc/polkit-1/rules.d/10-testing.rules \
|
|
|
|
|
--replace /bin/true ${coreutils}/bin/true \
|
|
|
|
|
--replace /bin/false ${coreutils}/bin/false
|
2021-10-30 11:28:44 +00:00
|
|
|
|
'';
|
2021-10-30 05:39:01 +00:00
|
|
|
|
|
2022-12-12 23:22:55 +00:00
|
|
|
|
postConfigure = lib.optionalString doCheck ''
|
2021-10-30 11:28:44 +00:00
|
|
|
|
# Unpacked by meson
|
|
|
|
|
chmod +x subprojects/mocklibc-1.0/bin/mocklibc
|
|
|
|
|
patchShebangs subprojects/mocklibc-1.0/bin/mocklibc
|
2021-10-30 05:39:01 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2018-07-06 20:41:41 +00:00
|
|
|
|
checkPhase = ''
|
2021-06-12 16:04:31 +00:00
|
|
|
|
runHook preCheck
|
|
|
|
|
|
2018-07-06 20:41:41 +00:00
|
|
|
|
# tests need access to the system bus
|
2021-10-30 11:28:44 +00:00
|
|
|
|
dbus-run-session --config-file=${./system_bus.conf} -- sh -c 'DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS meson test --print-errorlogs'
|
2021-06-12 16:04:31 +00:00
|
|
|
|
|
|
|
|
|
runHook postCheck
|
2018-07-06 20:41:41 +00:00
|
|
|
|
'';
|
2009-08-16 12:03:45 +00:00
|
|
|
|
|
2021-10-30 11:28:44 +00:00
|
|
|
|
postInstall = ''
|
|
|
|
|
# Move stuff from DESTDIR to proper location.
|
|
|
|
|
# We use rsync to merge the directories.
|
|
|
|
|
rsync --archive "${DESTDIR}/etc" "$out"
|
|
|
|
|
rm --recursive "${DESTDIR}/etc"
|
|
|
|
|
rsync --archive "${DESTDIR}${system}"/* "$out"
|
|
|
|
|
rm --recursive "${DESTDIR}${system}"/*
|
|
|
|
|
rmdir --parents --ignore-fail-on-non-empty "${DESTDIR}${system}"
|
2022-05-31 21:34:59 +00:00
|
|
|
|
for o in $(getAllOutputNames); do
|
2021-10-30 11:28:44 +00:00
|
|
|
|
rsync --archive "${DESTDIR}/''${!o}" "$(dirname "''${!o}")"
|
|
|
|
|
rm --recursive "${DESTDIR}/''${!o}"
|
|
|
|
|
done
|
|
|
|
|
# Ensure the DESTDIR is removed.
|
|
|
|
|
destdirContainer="$(dirname "${DESTDIR}")"
|
|
|
|
|
pushd "$destdirContainer"; rmdir --parents "''${DESTDIR##$destdirContainer/}${builtins.storeDir}"; popd
|
|
|
|
|
'';
|
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
|
homepage = "http://www.freedesktop.org/wiki/Software/polkit";
|
2009-08-13 07:55:11 +00:00
|
|
|
|
description = "A toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes";
|
2021-06-12 16:04:31 +00:00
|
|
|
|
license = licenses.lgpl2Plus;
|
2022-09-21 12:30:25 +00:00
|
|
|
|
platforms = platforms.linux;
|
2021-05-07 13:23:50 +00:00
|
|
|
|
maintainers = teams.freedesktop.members ++ (with maintainers; [ ]);
|
2009-08-13 07:55:11 +00:00
|
|
|
|
};
|
|
|
|
|
}
|