core/pkgs/by-name/db/dbus/make-dbus-conf.nix

38 lines
1.5 KiB
Nix
Raw Normal View History

2024-05-13 21:24:10 +00:00
{ runCommand, writeText, libxslt, dbus, findXMLCatalogs
, serviceDirectories ? [ ]
2024-05-02 00:46:19 +00:00
, suidHelper ? "/var/setuid-wrappers/dbus-daemon-launch-helper"
, apparmor ? "disabled" # one of enabled, disabled, required
}:
2024-05-13 21:24:10 +00:00
# DBus has two configuration parsers -- normal and "trivial", which is used
# for suid helper. Unfortunately the latter doesn't support <include>
# directive. That means that we can't just place our configuration to
# *-local.conf -- it needs to be in the main configuration file.
runCommand "dbus-1" {
inherit serviceDirectories suidHelper apparmor;
preferLocalBuild = true;
allowSubstitutes = false;
2024-05-02 00:46:19 +00:00
2024-05-13 21:24:10 +00:00
nativeBuildInputs = [ libxslt.bin findXMLCatalogs ];
2024-05-02 00:46:19 +00:00
2024-05-13 21:24:10 +00:00
buildInputs = [ dbus.out ];
} ''
mkdir -p $out
2024-05-02 00:46:19 +00:00
2024-05-13 21:24:10 +00:00
xsltproc --nonet \
--stringparam serviceDirectories "$serviceDirectories" \
--stringparam suidHelper "$suidHelper" \
--stringparam apparmor "$apparmor" \
${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \
> $out/system.conf
xsltproc --nonet \
--stringparam serviceDirectories "$serviceDirectories" \
--stringparam apparmor "$apparmor" \
${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \
> $out/session.conf
2024-05-02 00:46:19 +00:00
2024-05-13 21:24:10 +00:00
# check if files are empty or only contain space characters
grep -q '[^[:space:]]' "$out/system.conf" || (echo "\"$out/system.conf\" was generated incorrectly and is empty, try building again." && exit 1)
grep -q '[^[:space:]]' "$out/session.conf" || (echo "\"$out/session.conf\" was generated incorrectly and is empty, try building again." && exit 1)
''