<commit_before>{ stdenv
, lib
, fetchurl
, pkgconfig
, expat
, systemd
, libX11 ? null
, libICE ? null
, libSM ? null
, x11Support ? (stdenv.isLinux || stdenv.isDarwin)
, dbus
}:

assert
  x11Support ->
    libX11 != null && libICE != null && libSM != null;

stdenv.mkDerivation rec {
  pname = "dbus";
  version = "1.12.16";

  src = fetchurl {
    url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz";
    sha256 = "107ckxaff1cv4q6kmfdi2fb1nlsv03312a7kf6lb4biglhpjv8jl";
  };

  patches = lib.optional stdenv.isSunOS ./implement-getgrouplist.patch;

  postPatch = ''
    substituteInPlace tools/Makefile.in \
      --replace 'install-localstatelibDATA:' 'disabled:' \
      --replace 'install-data-local:' 'disabled:' \
      --replace 'installcheck-local:' 'disabled:'
    substituteInPlace bus/Makefile.in \
      --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':'
  '' + /* cleanup of runtime references */ ''
    substituteInPlace ./dbus/dbus-sysdeps-unix.c \
      --replace 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
    substituteInPlace ./tools/dbus-launch.c \
      --replace 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
  '';

  outputs = [ "out" "dev" "lib" "doc" ];

  nativeBuildInputs = [
    pkgconfig
  ];

  propagatedBuildInputs = [
    expat
  ];

  buildInputs = lib.optionals x11Support [
    libX11
    libICE
    libSM
  ] ++ lib.optional stdenv.isLinux systemd;
  # ToDo: optional selinux?<commit_msg>dbus: enable building with musl<commit_after>{ stdenv
, lib
, fetchurl
, pkgconfig
, expat
, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isMusl
, systemd
, libX11 ? null
, libICE ? null
, libSM ? null
, x11Support ? (stdenv.isLinux || stdenv.isDarwin)
, dbus
}:

assert
  x11Support ->
    libX11 != null && libICE != null && libSM != null;

assert enableSystemd -> systemd != null;

stdenv.mkDerivation rec {
  pname = "dbus";
  version = "1.12.16";

  src = fetchurl {
    url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz";
    sha256 = "107ckxaff1cv4q6kmfdi2fb1nlsv03312a7kf6lb4biglhpjv8jl";
  };

  patches = lib.optional stdenv.isSunOS ./implement-getgrouplist.patch;

  postPatch = ''
    substituteInPlace tools/Makefile.in \
      --replace 'install-localstatelibDATA:' 'disabled:' \
      --replace 'install-data-local:' 'disabled:' \
      --replace 'installcheck-local:' 'disabled:'
    substituteInPlace bus/Makefile.in \
      --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':'
  '' + /* cleanup of runtime references */ ''
    substituteInPlace ./dbus/dbus-sysdeps-unix.c \
      --replace 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
    substituteInPlace ./tools/dbus-launch.c \
      --replace 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
  '';

  outputs = [ "out" "dev" "lib" "doc" ];

  nativeBuildInputs = [
    pkgconfig
  ];

  propagatedBuildInputs = [
    expat
  ];

  buildInputs =
    lib.optionals x11Support [
      libX11
      libICE
      libSM
    ] ++ lib.optional enableSystemd systemd;
  # ToDo: optional selinux?
{'fraction_non_alphanumeric': 0.1539193906696287, 'fraction_numerical': 0.023484608060933037, 'mean_word_length': 3.163804491413474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1778325', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1184, 'n_words': 198}