polkit: fix building with useSystemd = false

The PKG_CONFIG_* environment variables are only read from when
systemd.pc is found.  This meant that the ! test -e "$DESTDIR" check
would fail when built without systemd.  Avoid that by handling the
systemd files unconditionally installed in lib the same way we do
for etc.
This commit is contained in:
Alyssa Ross
2025-03-28 10:40:49 +01:00
parent 339008865b
commit 12f68bf117
+13 -5
View File
@@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
pkg-config,
glib,
expat,
@@ -61,6 +62,12 @@ stdenv.mkDerivation rec {
# Allow changing base for paths in pkg-config file as before.
# https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/100
./0001-build-Use-datarootdir-in-Meson-generated-pkg-config-.patch
(fetchpatch {
name = "elogind.patch";
url = "https://github.com/polkit-org/polkit/commit/55ee1b70456eca8281dda9612c485c619122f202.patch";
hash = "sha256-XOsDyYFBDWxs0PGAgqm3OSUycKR8fYa2ySZqBl8EX7E=";
})
];
depsBuildBuild = [
@@ -120,10 +127,6 @@ stdenv.mkDerivation rec {
];
env = {
PKG_CONFIG_SYSTEMD_SYSTEMDSYSTEMUNITDIR = "${placeholder "out"}/lib/systemd/system";
PKG_CONFIG_SYSTEMD_SYSUSERS_DIR = "${placeholder "out"}/lib/sysusers.d";
PKG_CONFIG_SYSTEMD_TMPFILES_DIR = "${placeholder "out"}/lib/tmpfiles.d";
# 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.
@@ -144,6 +147,7 @@ stdenv.mkDerivation rec {
"-Dtests=${lib.boolToString doCheck}"
"-Dgtk_doc=${lib.boolToString withIntrospection}"
"-Dman=true"
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"-Dsession_tracking=${if useSystemd then "logind" else "elogind"}"
@@ -172,9 +176,13 @@ stdenv.mkDerivation rec {
mv "$DESTDIR/''${!o}" "''${!o}"
done
mv "$DESTDIR/etc" "$out"
mv "$DESTDIR/usr/lib"/{sysusers,tmpfiles}.d "$out/lib"
mv "$DESTDIR${system}/share"/* "$out/share"
# Ensure we did not forget to install anything.
rmdir --parents --ignore-fail-on-non-empty "$DESTDIR${builtins.storeDir}" "$DESTDIR${system}/share"
rmdir --parents --ignore-fail-on-non-empty \
"$DESTDIR${builtins.storeDir}" \
"$DESTDIR/usr/lib" \
"$DESTDIR${system}/share"
! test -e "$DESTDIR"
'';