diff --git a/pkgs/development/libraries/polkit/0001-build-Use-datarootdir-in-Meson-generated-pkg-config-.patch b/pkgs/development/libraries/polkit/0001-build-Use-datarootdir-in-Meson-generated-pkg-config-.patch new file mode 100644 index 000000000000..4e38660217fe --- /dev/null +++ b/pkgs/development/libraries/polkit/0001-build-Use-datarootdir-in-Meson-generated-pkg-config-.patch @@ -0,0 +1,53 @@ +From 7ba07551dfcd4ef9a87b8f0d9eb8b91fabcb41b3 Mon Sep 17 00:00:00 2001 +From: Jan Tojnar +Date: Mon, 1 Nov 2021 14:17:17 +0100 +Subject: [PATCH] build: Use datarootdir in Meson-generated pkg-config files +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +With datadir outside of prefix (currently unsupported by Meson[1] +but a frequent occurrence in Nixpkgs), the `datadir` entry, +in the `polkit-gobject-1` pkg-config file will be an absolute path. +This will prevent changing the base directory of `policydir` +with `--define-variable=prefix=…`, which many projects use +to install policy files to their own prefix. + +Previously, this worked without changes on Nixpkgs’s part because +the pkg-config template used by Autotools contained `@datarootdir@`, +which resolves to `$(prefix)/share`[2], taking no heed of the changed datadir. + +Similar issue can happen when a distribution package redefines datadir +like Debian does/did.[3] + +This patch changes Meson-based build system to use `$(prefix)/share` +in the generated pkg-config files, mirroring Autotools. + +--- + +1. Likely to change in the future: https://github.com/mesonbuild/meson/issues/2561#issuecomment-939253717 +2. https://www.gnu.org/prep/standards/html_node/Directory-Variables.html +3. https://blogs.gnome.org/hughsie/2014/06/16/datarootdir-v-s-datadir/ +--- + src/polkit/meson.build | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/src/polkit/meson.build b/src/polkit/meson.build +index 63dc1e85..c92cb70f 100644 +--- a/src/polkit/meson.build ++++ b/src/polkit/meson.build +@@ -113,9 +113,8 @@ pkg.generate( + requires: common_deps, + variables: [ + 'exec_prefix=${prefix}', +- 'datadir=' + ('${prefix}' / pk_datadir), +- 'policydir=' + ('${datadir}' / pk_actiondir), +- 'actiondir=' + ('${datadir}' / pk_actiondir), ++ 'policydir=' + ('${prefix}' / 'share' / pk_actiondir), ++ 'actiondir=' + ('${prefix}' / 'share' / pk_actiondir), + 'pkcheck_supports_uid=true', + ], + ) +-- +GitLab + diff --git a/pkgs/development/libraries/polkit/default.nix b/pkgs/development/libraries/polkit/default.nix index dabba056b487..69b2233a8559 100644 --- a/pkgs/development/libraries/polkit/default.nix +++ b/pkgs/development/libraries/polkit/default.nix @@ -1,6 +1,6 @@ { lib , stdenv -, fetchFromGitLab +, fetchFromGitHub , pkg-config , glib , expat @@ -10,7 +10,6 @@ , ninja , perl , python3 -, fetchpatch , gettext , duktape , gobject-introspection @@ -38,26 +37,22 @@ let in stdenv.mkDerivation rec { pname = "polkit"; - version = "123"; + version = "124"; outputs = [ "bin" "dev" "out" ]; # small man pages in $bin # Tarballs do not contain subprojects. - src = fetchFromGitLab { - domain = "gitlab.freedesktop.org"; - owner = "polkit"; + src = fetchFromGitHub { + owner = "polkit-org"; repo = "polkit"; rev = version; - hash = "sha256-/kjWkh6w2FYgtYWzw3g3GlWJKKpkJ3cqwfE0iDqJctw="; + hash = "sha256-Vc9G2xK6U1cX+xW2BnKp3oS/ACbSXS/lztbFP5oJOlM="; }; 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"; - sha256 = "ebbLILncq1hAZTBMsLm+vDGw6j0iQ0crGyhzyLZQgKA="; - }) + ./0001-build-Use-datarootdir-in-Meson-generated-pkg-config-.patch ]; depsBuildBuild = [ @@ -108,10 +103,14 @@ stdenv.mkDerivation rec { ])) ]; + env = { + PKG_CONFIG_SYSTEMD_SYSTEMDSYSTEMUNITDIR = "${placeholder "out"}/lib/systemd/system"; + PKG_CONFIG_SYSTEMD_SYSUSERS_DIR = "${placeholder "out"}/lib/sysusers.d"; + }; + mesonFlags = [ "--datadir=${system}/share" "--sysconfdir=/etc" - "-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system" "-Dpolkitd_user=polkituser" #TODO? config.ids.uids.polkituser "-Dos_type=redhat" # only affects PAM includes "-Dintrospection=${lib.boolToString withIntrospection}" @@ -175,7 +174,7 @@ stdenv.mkDerivation rec { ''; meta = with lib; { - homepage = "https://gitlab.freedesktop.org/polkit/polkit/"; + homepage = "https://github.com/polkit-org/polkit"; description = "A toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes"; license = licenses.lgpl2Plus; platforms = platforms.linux;