From 300c9a6c3d73cb486fca6385271acc2cd341ed51 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 16 Feb 2017 14:55:03 +0300 Subject: [PATCH 1/3] dbus: use /etc as datadir, install dtd --- pkgs/development/libraries/dbus/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/dbus/default.nix b/pkgs/development/libraries/dbus/default.nix index 7743c1e3f80..49b71ff9974 100644 --- a/pkgs/development/libraries/dbus/default.nix +++ b/pkgs/development/libraries/dbus/default.nix @@ -50,7 +50,8 @@ self = stdenv.mkDerivation { "--with-systemdsystemunitdir=$(out)/etc/systemd/system" "--with-systemduserunitdir=$(out)/etc/systemd/user" "--enable-user-session" - "--libexecdir=$(out)/libexec" # we don't need dbus-daemon-launch-helper + "--datadir=/etc" + "--libexecdir=$(out)/libexec" ] ++ lib.optional (!x11Support) "--without-x"; # Enable X11 autolaunch support in libdbus. This doesn't actually depend on X11 @@ -63,7 +64,12 @@ self = stdenv.mkDerivation { doCheck = true; - installFlags = [ "sysconfdir=$(out)/etc" ]; + installFlags = [ "sysconfdir=$(out)/etc" "datadir=$(out)/share" ]; + + postInstall = '' + mkdir -p $doc/share/xml/dbus + cp doc/*.dtd $doc/share/xml/dbus + ''; # it's executed from $lib by absolute path postFixup = '' From 3e23ec44503df219b8a705357eafd1f3960f34d9 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 16 Feb 2017 14:55:38 +0300 Subject: [PATCH 2/3] makeDBusConf: init Use XSLT transform to modify stock dbus configuration file. This is needed because some dbus components doesn't support so we need to put our core configuration in the main file. --- .../libraries/dbus/make-dbus-conf.nix | 27 +++++++++++++++ .../libraries/dbus/make-session-conf.xsl | 30 ++++++++++++++++ .../libraries/dbus/make-system-conf.xsl | 34 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 +++ 4 files changed, 96 insertions(+) create mode 100644 pkgs/development/libraries/dbus/make-dbus-conf.nix create mode 100644 pkgs/development/libraries/dbus/make-session-conf.xsl create mode 100644 pkgs/development/libraries/dbus/make-system-conf.xsl diff --git a/pkgs/development/libraries/dbus/make-dbus-conf.nix b/pkgs/development/libraries/dbus/make-dbus-conf.nix new file mode 100644 index 00000000000..7e35a9162c8 --- /dev/null +++ b/pkgs/development/libraries/dbus/make-dbus-conf.nix @@ -0,0 +1,27 @@ +{ runCommand, libxslt, dbus, serviceDirectories ? [], suidHelper ? "/var/setuid-wrappers/dbus-daemon-launch-helper" }: + +/* DBus has two configuration parsers -- normal and "trivial", which is used + * for suid helper. Unfortunately the latter doesn't support + * 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" + { + buildInputs = [ libxslt ]; + inherit serviceDirectories suidHelper; + } + '' + mkdir -p $out + + xsltproc \ + --stringparam serviceDirectories "$serviceDirectories" \ + --stringparam suidHelper "$suidHelper" \ + --path ${dbus.doc}/share/xml/dbus \ + ${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \ + > $out/system.conf + xsltproc \ + --stringparam serviceDirectories "$serviceDirectories" \ + --path ${dbus.doc}/share/xml/dbus \ + ${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \ + > $out/session.conf + '' diff --git a/pkgs/development/libraries/dbus/make-session-conf.xsl b/pkgs/development/libraries/dbus/make-session-conf.xsl new file mode 100644 index 00000000000..bc73369af94 --- /dev/null +++ b/pkgs/development/libraries/dbus/make-session-conf.xsl @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + /share/dbus-1/services + /etc/dbus-1/session.d + + + + + diff --git a/pkgs/development/libraries/dbus/make-system-conf.xsl b/pkgs/development/libraries/dbus/make-system-conf.xsl new file mode 100644 index 00000000000..3d8b823437d --- /dev/null +++ b/pkgs/development/libraries/dbus/make-system-conf.xsl @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + /share/dbus-1/system-services + /etc/dbus-1/system.d + + + + + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3ba672c477d..0dadf9b99ff 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7094,6 +7094,11 @@ with pkgs; dbus_libs = dbus; dbus_daemon = dbus.daemon; + makeDBusConf = { suidHelper, serviceDirectories }: + callPackage ../development/libraries/dbus/make-dbus-conf.nix { + inherit suidHelper serviceDirectories; + }; + dee = callPackage ../development/libraries/dee { }; dhex = callPackage ../applications/editors/dhex { }; From ac0cdc1952fb0133ec26f2fdde5a77a648d3c1cd Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 16 Feb 2017 14:56:45 +0300 Subject: [PATCH 3/3] dbus service: use makeDBusConf --- .../system/dbus-session-local.conf.in | 5 ---- .../services/system/dbus-system-local.conf.in | 6 ---- nixos/modules/services/system/dbus.nix | 30 +++---------------- 3 files changed, 4 insertions(+), 37 deletions(-) delete mode 100644 nixos/modules/services/system/dbus-session-local.conf.in delete mode 100644 nixos/modules/services/system/dbus-system-local.conf.in diff --git a/nixos/modules/services/system/dbus-session-local.conf.in b/nixos/modules/services/system/dbus-session-local.conf.in deleted file mode 100644 index 5fd6f80a353..00000000000 --- a/nixos/modules/services/system/dbus-session-local.conf.in +++ /dev/null @@ -1,5 +0,0 @@ - - - @extra@ - diff --git a/nixos/modules/services/system/dbus-system-local.conf.in b/nixos/modules/services/system/dbus-system-local.conf.in deleted file mode 100644 index edbb476f585..00000000000 --- a/nixos/modules/services/system/dbus-system-local.conf.in +++ /dev/null @@ -1,6 +0,0 @@ - - - @servicehelper@ - @extra@ - diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix index 33bc890a78c..643bec18814 100644 --- a/nixos/modules/services/system/dbus.nix +++ b/nixos/modules/services/system/dbus.nix @@ -10,32 +10,10 @@ let homeDir = "/run/dbus"; - systemExtraxml = concatStrings (flip concatMap cfg.packages (d: [ - "${d}/share/dbus-1/system-services" - "${d}/etc/dbus-1/system.d" - ])); - - sessionExtraxml = concatStrings (flip concatMap cfg.packages (d: [ - "${d}/share/dbus-1/services" - "${d}/etc/dbus-1/session.d" - ])); - - configDir = pkgs.runCommand "dbus-conf" - { preferLocalBuild = true; - allowSubstitutes = false; - } - '' - mkdir -p $out - - sed '${./dbus-system-local.conf.in}' \ - -e 's,@servicehelper@,${config.security.wrapperDir}/dbus-daemon-launch-helper,g' \ - -e 's,@extra@,${systemExtraxml},' \ - > "$out/system-local.conf" - - sed '${./dbus-session-local.conf.in}' \ - -e 's,@extra@,${sessionExtraxml},' \ - > "$out/session-local.conf" - ''; + configDir = pkgs.makeDBusConf { + suidHelper = "${config.security.wrapperDir}/dbus-daemon-launch-helper"; + serviceDirectories = cfg.packages; + }; in