{stdenv, m4, yasm, cmark, groff}:

stdenv.mkDerivation {
  name = "libk";
  version = "0.0.0";

  src = stdenv.lib.cleanSource ../.;

  # Need to figure out how split builds work... but that also kinda needs
  # an install script first, so.
  nativeBuildInputs = [ m4 yasm cmark groff ];

  buildPhase = ''
    patchShebangs --build global/build-id.sh global/build-manpage.sh
    env os=lin arch=x86 bits=64 doc_pdf=false library=both \
    bash build.sh
  '';

  installPhase = ''
    env prefix=$prefix bash install.sh
  '';

  meta = with stdenv.lib; {
    description = "A modern replacement for libc";
    homepage = https://c.hale.su/libk;
    changelog = "https://c.hale.su/libk/timeline";
    license = licenses.agpl3;
    # Doesn't actually match w/ supported platforms, but...
    platforms = platforms.unix;
  };
}
