lol

Merge pull request #22864 from abbradar/dbus-etc

Redo DBus configuration

authored by

Nikolay Amiantov and committed by
GitHub
8ecd5c40 101d90d1

+108 -39
-5
nixos/modules/services/system/dbus-session-local.conf.in
··· 1 - <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" 2 - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> 3 - <busconfig> 4 - @extra@ 5 - </busconfig>
-6
nixos/modules/services/system/dbus-system-local.conf.in
··· 1 - <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" 2 - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> 3 - <busconfig> 4 - <servicehelper>@servicehelper@</servicehelper> 5 - @extra@ 6 - </busconfig>
+4 -26
nixos/modules/services/system/dbus.nix
··· 10 10 11 11 homeDir = "/run/dbus"; 12 12 13 - systemExtraxml = concatStrings (flip concatMap cfg.packages (d: [ 14 - "<servicedir>${d}/share/dbus-1/system-services</servicedir>" 15 - "<includedir>${d}/etc/dbus-1/system.d</includedir>" 16 - ])); 17 - 18 - sessionExtraxml = concatStrings (flip concatMap cfg.packages (d: [ 19 - "<servicedir>${d}/share/dbus-1/services</servicedir>" 20 - "<includedir>${d}/etc/dbus-1/session.d</includedir>" 21 - ])); 22 - 23 - configDir = pkgs.runCommand "dbus-conf" 24 - { preferLocalBuild = true; 25 - allowSubstitutes = false; 26 - } 27 - '' 28 - mkdir -p $out 29 - 30 - sed '${./dbus-system-local.conf.in}' \ 31 - -e 's,@servicehelper@,${config.security.wrapperDir}/dbus-daemon-launch-helper,g' \ 32 - -e 's,@extra@,${systemExtraxml},' \ 33 - > "$out/system-local.conf" 34 - 35 - sed '${./dbus-session-local.conf.in}' \ 36 - -e 's,@extra@,${sessionExtraxml},' \ 37 - > "$out/session-local.conf" 38 - ''; 13 + configDir = pkgs.makeDBusConf { 14 + suidHelper = "${config.security.wrapperDir}/dbus-daemon-launch-helper"; 15 + serviceDirectories = cfg.packages; 16 + }; 39 17 40 18 in 41 19
+8 -2
pkgs/development/libraries/dbus/default.nix
··· 50 50 "--with-systemdsystemunitdir=$(out)/etc/systemd/system" 51 51 "--with-systemduserunitdir=$(out)/etc/systemd/user" 52 52 "--enable-user-session" 53 - "--libexecdir=$(out)/libexec" # we don't need dbus-daemon-launch-helper 53 + "--datadir=/etc" 54 + "--libexecdir=$(out)/libexec" 54 55 ] ++ lib.optional (!x11Support) "--without-x"; 55 56 56 57 # Enable X11 autolaunch support in libdbus. This doesn't actually depend on X11 ··· 63 64 64 65 doCheck = true; 65 66 66 - installFlags = [ "sysconfdir=$(out)/etc" ]; 67 + installFlags = [ "sysconfdir=$(out)/etc" "datadir=$(out)/share" ]; 68 + 69 + postInstall = '' 70 + mkdir -p $doc/share/xml/dbus 71 + cp doc/*.dtd $doc/share/xml/dbus 72 + ''; 67 73 68 74 # it's executed from $lib by absolute path 69 75 postFixup = ''
+27
pkgs/development/libraries/dbus/make-dbus-conf.nix
··· 1 + { runCommand, libxslt, dbus, serviceDirectories ? [], suidHelper ? "/var/setuid-wrappers/dbus-daemon-launch-helper" }: 2 + 3 + /* DBus has two configuration parsers -- normal and "trivial", which is used 4 + * for suid helper. Unfortunately the latter doesn't support <include> 5 + * directive. That means that we can't just place our configuration to 6 + * *-local.conf -- it needs to be in the main configuration file. 7 + */ 8 + runCommand "dbus-1" 9 + { 10 + buildInputs = [ libxslt ]; 11 + inherit serviceDirectories suidHelper; 12 + } 13 + '' 14 + mkdir -p $out 15 + 16 + xsltproc \ 17 + --stringparam serviceDirectories "$serviceDirectories" \ 18 + --stringparam suidHelper "$suidHelper" \ 19 + --path ${dbus.doc}/share/xml/dbus \ 20 + ${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \ 21 + > $out/system.conf 22 + xsltproc \ 23 + --stringparam serviceDirectories "$serviceDirectories" \ 24 + --path ${dbus.doc}/share/xml/dbus \ 25 + ${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \ 26 + > $out/session.conf 27 + ''
+30
pkgs/development/libraries/dbus/make-session-conf.xsl
··· 1 + <?xml version="1.0"?> 2 + 3 + <!-- 4 + This script copies the original system.conf from the dbus 5 + distribution, but sets paths from $serviceDirectories parameter 6 + and suid helper from $suidHelper parameter. 7 + --> 8 + 9 + <xsl:stylesheet version="1.0" 10 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 11 + xmlns:str="http://exslt.org/strings" 12 + extension-element-prefixes="str" 13 + > 14 + 15 + <xsl:output method='xml' encoding="UTF-8" doctype-system="busconfig.dtd" /> 16 + 17 + <xsl:param name="serviceDirectories" /> 18 + 19 + <xsl:template match="/busconfig"> 20 + <busconfig> 21 + <xsl:copy-of select="child::node()[name() != 'include' and name() != 'standard_session_servicedirs' and name() != 'servicedir' and name() != 'includedir']" /> 22 + 23 + <xsl:for-each select="str:tokenize($serviceDirectories)"> 24 + <servicedir><xsl:value-of select="." />/share/dbus-1/services</servicedir> 25 + <includedir><xsl:value-of select="." />/etc/dbus-1/session.d</includedir> 26 + </xsl:for-each> 27 + </busconfig> 28 + </xsl:template> 29 + 30 + </xsl:stylesheet>
+34
pkgs/development/libraries/dbus/make-system-conf.xsl
··· 1 + <?xml version="1.0"?> 2 + 3 + <!-- 4 + This script copies the original system.conf from the dbus 5 + distribution, but sets paths from $serviceDirectories parameter 6 + and suid helper from $suidHelper parameter. 7 + --> 8 + 9 + <xsl:stylesheet version="1.0" 10 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 11 + xmlns:str="http://exslt.org/strings" 12 + extension-element-prefixes="str" 13 + > 14 + 15 + <xsl:output method='xml' encoding="UTF-8" doctype-system="busconfig.dtd" /> 16 + 17 + <xsl:param name="serviceDirectories" /> 18 + <xsl:param name="suidHelper" /> 19 + 20 + <xsl:template match="/busconfig"> 21 + <busconfig> 22 + <xsl:copy-of select="child::node()[name() != 'include' and name() != 'standard_system_servicedirs' and name() != 'servicehelper' and name() != 'servicedir' and name() != 'includedir']" /> 23 + 24 + <!-- set suid helper --> 25 + <servicehelper><xsl:value-of select="$suidHelper" /></servicehelper> 26 + 27 + <xsl:for-each select="str:tokenize($serviceDirectories)"> 28 + <servicedir><xsl:value-of select="." />/share/dbus-1/system-services</servicedir> 29 + <includedir><xsl:value-of select="." />/etc/dbus-1/system.d</includedir> 30 + </xsl:for-each> 31 + </busconfig> 32 + </xsl:template> 33 + 34 + </xsl:stylesheet>
+5
pkgs/top-level/all-packages.nix
··· 7089 7089 dbus_libs = dbus; 7090 7090 dbus_daemon = dbus.daemon; 7091 7091 7092 + makeDBusConf = { suidHelper, serviceDirectories }: 7093 + callPackage ../development/libraries/dbus/make-dbus-conf.nix { 7094 + inherit suidHelper serviceDirectories; 7095 + }; 7096 + 7092 7097 dee = callPackage ../development/libraries/dee { }; 7093 7098 7094 7099 dhex = callPackage ../applications/editors/dhex { };