<commit_before>{ lib
, stdenv
, autoreconfHook
, buildPackages
, coreutils
, fetchFromGitHub
, jansson
, libiconv
, perl
, pkg-config
, python3
, libseccomp
, libyaml
, pcre2
, libxml2
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "universal-ctags";
  version = "5.9.20221106.0";

  src = fetchFromGitHub {
    owner = "universal-ctags";
    repo = "ctags";
    rev = "p${finalAttrs.version}";
    hash = "sha256-6piWdofvlX+ysXmRPnQc7PlZuHSyVqdVxOztY2+Pcss=";
  };

  depsBuildBuild = [
    buildPackages.stdenv.cc
  ];

  nativeBuildInputs = [
    autoreconfHook
    perl
    pkg-config
    (python3.withPackages (p: [ p.docutils ]))
  ];

  buildInputs = [
    libseccomp
    libyaml
    pcre2
    libxml2
    jansson
  ]
  ++ lib.optional stdenv.isDarwin libiconv;

  configureFlags = [ "--enable-tmpdir=/tmp" ];

  patches = [
    ./000-nixos-specific.patch
  ];

  postPatch = ''
    substituteInPlace Tmain/utils.sh \
      --replace /bin/echo ${coreutils}/bin/echo

    patchShebangs misc/*
  '';

  doCheck = true;

  checkFlags = [
    "man-test" "tlib" "tmain" "tutil" "units"
  ];

  meta = with lib; {
    homepage = "https://docs.ctags.io/en/latest/";
    description = "A maintained ctags implementation";<commit_msg>universal-ctags: Fix for Darwin<commit_after>{ lib
, stdenv
, autoreconfHook
, buildPackages
, coreutils
, fetchFromGitHub
, jansson
, libiconv
, perl
, pkg-config
, python3
, libseccomp
, libyaml
, pcre2
, libxml2
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "universal-ctags";
  version = "5.9.20221106.0";

  src = fetchFromGitHub {
    owner = "universal-ctags";
    repo = "ctags";
    rev = "p${finalAttrs.version}";
    hash = "sha256-6piWdofvlX+ysXmRPnQc7PlZuHSyVqdVxOztY2+Pcss=";
  };

  depsBuildBuild = [
    buildPackages.stdenv.cc
  ];

  nativeBuildInputs = [
    autoreconfHook
    perl
    pkg-config
    (python3.withPackages (p: [ p.docutils ]))
  ];

  buildInputs = [
    libyaml
    pcre2
    libxml2
    jansson
  ]
  ++ lib.optional stdenv.isDarwin libiconv
  ++ lib.optional stdenv.isLinux libseccomp;

  configureFlags = [ "--enable-tmpdir=/tmp" ];

  patches = [
    ./000-nixos-specific.patch
  ];

  postPatch = ''
    substituteInPlace Tmain/utils.sh \
      --replace /bin/echo ${coreutils}/bin/echo

    patchShebangs misc/*
  '';

  doCheck = true;

  checkFlags = [
    "man-test" "tlib" "tmain" "tutil" "units"
  ];

  meta = with lib; {
    homepage = "https://docs.ctags.io/en/latest/";
    description = "A maintained ctags implementation";
{'fraction_non_alphanumeric': 0.13757455268389662, 'fraction_numerical': 0.020675944333996023, 'mean_word_length': 2.9435736677115987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3015450', 'n_tokens_mistral': 1042, 'n_tokens_neox': 985, 'n_words': 164}