about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix
blob: 0a8b630d073b10796a8188c5d47fffd96b54cf9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ runCommand
, writeText
, libxslt
, dbus
, findXMLCatalogs
, serviceDirectories ? []
, suidHelper ? "/var/setuid-wrappers/dbus-daemon-launch-helper"
, apparmor ? "disabled" # one of enabled, disabled, required
}:

/* 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;

    nativeBuildInputs = [
      libxslt.bin
      findXMLCatalogs
    ];

    buildInputs = [
      dbus.out
    ];
  }
  ''
    mkdir -p $out

    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

    # 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)
  ''