anchor.diff:    # also other parts than "libs" need this statically linked lib
     makeInternalLib = "(cd dbus && make libdbus-internal.la)";
   
  +  systemdOrEmpty = stdenv.lib.optional stdenv.isLinux systemd;
   
     # A generic builder for individual parts (subdirs) of D-Bus
     dbus_drv = name: subdirs: merge: stdenv.mkDerivation (lib.mergeAttrsByFuncDefaultsClean [{
  
positive.code: 
    tools = dbus_drv "tools" "tools" {
      configureFlags = [ "--with-dbus-daemondir=${daemon}/bin" ];
      buildInputs = buildInputsX ++ [ libs daemon systemd dbus_glib ];
      NIX_CFLAGS_LINK = "-Wl,--as-needed -ldbus-1";
    };
  
    daemon = dbus_drv "daemon" "bus" {
      preBuild = makeInternalLib;
      buildInputs = [ systemd ];
    };
  
    # Some of the tests don't work yet; in fact, @vcunat tried several packages
    # containing dbus testing, and all of them have some test failure.
    tests = dbus_drv "tests" "test" {
      preBuild = makeInternalLib;
      buildInputs = buildInputsX ++ [ systemd libs tools daemon dbus_glib python ];
      NIX_CFLAGS_LINK = "-Wl,--as-needed -ldbus-1";
    };
  
  
negative.code: 
    } merge ]);
  
    libs = dbus_drv "libs" "dbus" ({
      # Enable X11 autolaunch support in libdbus. This doesn't actually depend on X11
      # (it just execs dbus-launch in dbus.tools), contrary to what the configure script demands.
      NIX_CFLAGS_COMPILE = "-DDBUS_ENABLE_X11_AUTOLAUNCH=1";
    } // stdenv.lib.optionalAttrs (systemdOrEmpty != []) {
      buildInputs = [ systemd.headers ];
      patches = [ ./systemd.patch ]; # bypass systemd detection
    });
  
  
  in rec {
  
  