<commit_before>{ stdenv, fetchurl, pkgconfig, intltool, gperf, libcap, dbus, kmod
, xz, pam, acl, cryptsetup, libuuid, m4, utillinux
, glib, kbd, libxslt, coreutils, libgcrypt, sysvtools, docbook_xsl
}:

assert stdenv.gcc.libc or null != null;

stdenv.mkDerivation rec {
  name = "systemd-201";

  src = fetchurl {
    url = "http://www.freedesktop.org/software/systemd/${name}.tar.xz";
    sha256 = "046cr1q7xv7bslzc16g8zz8nddf64lw8v01isw1204n21cd9yafn";
  };

  patches =
    [ ./0001-Make-systemctl-daemon-reexec-do-the-right-thing-on-N.patch
      ./0002-Ignore-duplicate-paths-in-systemctl-start.patch
      ./0003-Start-device-units-for-uninitialised-encrypted-devic.patch
      ./0004-Set-switch-to-configuration-hints-for-some-units.patch
      ./0005-sysinit.target-Drop-the-dependency-on-local-fs.targe.patch
      ./0006-Don-t-call-plymouth-quit.patch
      ./0007-Ignore-IPv6-link-local-addresses.patch
      ./0008-Don-t-try-to-unmount-nix-or-nix-store.patch
    ] ++ stdenv.lib.optional stdenv.isArm ./libc-bug-accept4-arm.patch;

  buildInputs =
    [ pkgconfig intltool gperf libcap dbus kmod xz pam acl
      /* cryptsetup */ libuuid m4 glib libxslt libgcrypt docbook_xsl
    ];

  configureFlags =
    [ "--localstatedir=/var"
      "--sysconfdir=/etc"
      "--with-rootprefix=$(out)"
      "--with-kbd-loadkeys=${kbd}/bin/loadkeys"
      "--with-kbd-setfont=${kbd}/bin/setfont"
      "--with-rootprefix=$(out)"
      "--with-dbusinterfacedir=$(out)/share/dbus-1/interfaces"
      "--with-dbuspolicydir=$(out)/etc/dbus-1/system.d"
      "--with-dbussystemservicedir=$(out)/share/dbus-1/system-services"
      "--with-dbussessionservicedir=$(out)/share/dbus-1/services"
      "--with-firmware-path=/root/test-firmware:/run/current-system/firmware"
      "--with-tty-gid=3" # tty in NixOS has gid 3
    ];

  preConfigure =
    ''
      # FIXME: patch this in systemd properly (and send upstream).
      # FIXME: use sulogin from util-linux once updated.
      for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.m4.in; do
        test -e $i
        substituteInPlace $i \
          --replace /bin/mount ${utillinux}/bin/mount \
          --replace /bin/umount ${utillinux}/bin/umount \
          --replace /sbin/swapon ${utillinux}/sbin/swapon \
          --replace /sbin/swapoff ${utillinux}/sbin/swapoff \
          --replace /sbin/fsck ${utillinux}/sbin/fsck \
          --replace /bin/echo ${coreutils}/bin/echo \
          --replace /sbin/sulogin ${sysvtools}/sbin/sulogin
      done<commit_msg>systemd: patch hardcoded "/bin/cat" in systemd-cat<commit_after>{ stdenv, fetchurl, pkgconfig, intltool, gperf, libcap, dbus, kmod
, xz, pam, acl, cryptsetup, libuuid, m4, utillinux
, glib, kbd, libxslt, coreutils, libgcrypt, sysvtools, docbook_xsl
}:

assert stdenv.gcc.libc or null != null;

stdenv.mkDerivation rec {
  name = "systemd-201";

  src = fetchurl {
    url = "http://www.freedesktop.org/software/systemd/${name}.tar.xz";
    sha256 = "046cr1q7xv7bslzc16g8zz8nddf64lw8v01isw1204n21cd9yafn";
  };

  patches =
    [ ./0001-Make-systemctl-daemon-reexec-do-the-right-thing-on-N.patch
      ./0002-Ignore-duplicate-paths-in-systemctl-start.patch
      ./0003-Start-device-units-for-uninitialised-encrypted-devic.patch
      ./0004-Set-switch-to-configuration-hints-for-some-units.patch
      ./0005-sysinit.target-Drop-the-dependency-on-local-fs.targe.patch
      ./0006-Don-t-call-plymouth-quit.patch
      ./0007-Ignore-IPv6-link-local-addresses.patch
      ./0008-Don-t-try-to-unmount-nix-or-nix-store.patch
    ] ++ stdenv.lib.optional stdenv.isArm ./libc-bug-accept4-arm.patch;

  buildInputs =
    [ pkgconfig intltool gperf libcap dbus kmod xz pam acl
      /* cryptsetup */ libuuid m4 glib libxslt libgcrypt docbook_xsl
    ];

  configureFlags =
    [ "--localstatedir=/var"
      "--sysconfdir=/etc"
      "--with-rootprefix=$(out)"
      "--with-kbd-loadkeys=${kbd}/bin/loadkeys"
      "--with-kbd-setfont=${kbd}/bin/setfont"
      "--with-rootprefix=$(out)"
      "--with-dbusinterfacedir=$(out)/share/dbus-1/interfaces"
      "--with-dbuspolicydir=$(out)/etc/dbus-1/system.d"
      "--with-dbussystemservicedir=$(out)/share/dbus-1/system-services"
      "--with-dbussessionservicedir=$(out)/share/dbus-1/services"
      "--with-firmware-path=/root/test-firmware:/run/current-system/firmware"
      "--with-tty-gid=3" # tty in NixOS has gid 3
    ];

  preConfigure =
    ''
      # FIXME: patch this in systemd properly (and send upstream).
      # FIXME: use sulogin from util-linux once updated.
      for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.m4.in src/journal/cat.c; do
        test -e $i
        substituteInPlace $i \
          --replace /bin/mount ${utillinux}/bin/mount \
          --replace /bin/umount ${utillinux}/bin/umount \
          --replace /sbin/swapon ${utillinux}/sbin/swapon \
          --replace /sbin/swapoff ${utillinux}/sbin/swapoff \
          --replace /sbin/fsck ${utillinux}/sbin/fsck \
          --replace /bin/echo ${coreutils}/bin/echo \
          --replace /bin/cat ${coreutils}/bin/cat \
          --replace /sbin/sulogin ${sysvtools}/sbin/sulogin
      done
{'fraction_non_alphanumeric': 0.15884680610514415, 'fraction_numerical': 0.026757113246655362, 'mean_word_length': 2.6759002770083105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5000617', 'n_tokens_mistral': 2102, 'n_tokens_neox': 1960, 'n_words': 288}