<commit_before>{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, wxGTK
, pkg-config
, python3
, gettext
, file
, libvorbis
, libmad
, libjack2
, lv2
, lilv
, serd
, sord
, sratom
, suil
, alsaLib
, libsndfile
, soxr
, flac
, twolame
, expat
, libid3tag
, libopus
, ffmpeg
, soundtouch
, pcre /*, portaudio - given up fighting their portaudio.patch */
, at-spi2-core ? null
, dbus ? null
, epoxy ? null
, libXdmcp ? null
, libXtst ? null
, libpthreadstubs ? null
, libselinux ? null
, libsepol ? null
, libxkbcommon ? null
, utillinux ? null
}:

# TODO
# - as of 2.4.2, GTK2 is still the recommended version ref https://www.audacityteam.org/download/source/ check if that changes in future versions
# - detach sbsms

stdenv.mkDerivation rec {
  pname = "audacity";
  version = "2.4.2";

  src = fetchFromGitHub {
    owner = "audacity";
    repo = "audacity";
    rev = "Audacity-${version}";
    sha256 = "sha256-hpRTo5B0EMyzORopsNPOgv6mohBkwJfWfCLnPvFmdFI=";
  };

  patches = [
    (fetchpatch {
      url = "https://github.com/audacity/audacity/commit/a070b5d8a8ba10fb86edba6aeb8fdab0f66ba408.patch";
      sha256 = "sha256-8UZupGcN+/tytAhyy5T1P0nufvsQPeyLgOUMGt7l8Oc=";
      name = "audacity_xdg_paths.patch";
    })
  ];

  # this file *should* be generated by cmake but as of 2.4.2 isn't yet
  postPatch = ''
    touch src/RevisionIdent.h
  '';

  # workaround for a broken cmake. Drop it with a later version to see if it works.
  # https://github.com/NixOS/nixpkgs/issues/94905
  cmakeFlags = lib.optional stdenv.isLinux "-DCMAKE_OSX_ARCHITECTURES=";

  # audacity only looks for ffmpeg at runtime, so we need to link it in manually
  NIX_LDFLAGS = toString [
    # ffmpeg
    "-lavcodec"
    "-lavdevice"
    "-lavfilter"
    "-lavformat"
    "-lavresample"
    "-lavutil"
    "-lpostproc"
    "-lswresample"
    "-lswscale"
  ];

  nativeBuildInputs = [ cmake gettext pkg-config python3 ];

  buildInputs = [
    alsaLib
    expat
    ffmpeg
    file
    flac
    libid3tag
    libjack2
    libmad
    libopus
    libsndfile
    libvorbis
    lilv
    lv2
    pcre
    serd
    sord
    soundtouch
    soxr
    sratom
    suil
    twolame
    wxGTK
    wxGTK.gtk
  ] ++ lib.optionals stdenv.isLinux [
    at-spi2-core
    dbus
    epoxy
    libXdmcp
    libXtst
    libpthreadstubs
    libxkbcommon
    libselinux
    libsepol
    utillinux
  ];

  doCheck = false; # Test fails

  meta = with lib; {
    description = "Sound editor with graphical UI";
    homepage = "https://www.audacityteam.org/";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ lheckemann ];
    platforms = intersectLists platforms.linux platforms.x86; # fails on ARM<commit_msg>audacity: change meta.platforms to platforms.linux<commit_after>{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, wxGTK
, pkg-config
, python3
, gettext
, file
, libvorbis
, libmad
, libjack2
, lv2
, lilv
, serd
, sord
, sratom
, suil
, alsaLib
, libsndfile
, soxr
, flac
, twolame
, expat
, libid3tag
, libopus
, ffmpeg
, soundtouch
, pcre /*, portaudio - given up fighting their portaudio.patch */
, at-spi2-core ? null
, dbus ? null
, epoxy ? null
, libXdmcp ? null
, libXtst ? null
, libpthreadstubs ? null
, libselinux ? null
, libsepol ? null
, libxkbcommon ? null
, utillinux ? null
}:

# TODO
# - as of 2.4.2, GTK2 is still the recommended version ref https://www.audacityteam.org/download/source/ check if that changes in future versions
# - detach sbsms

stdenv.mkDerivation rec {
  pname = "audacity";
  version = "2.4.2";

  src = fetchFromGitHub {
    owner = "audacity";
    repo = "audacity";
    rev = "Audacity-${version}";
    sha256 = "sha256-hpRTo5B0EMyzORopsNPOgv6mohBkwJfWfCLnPvFmdFI=";
  };

  patches = [
    (fetchpatch {
      url = "https://github.com/audacity/audacity/commit/a070b5d8a8ba10fb86edba6aeb8fdab0f66ba408.patch";
      sha256 = "sha256-8UZupGcN+/tytAhyy5T1P0nufvsQPeyLgOUMGt7l8Oc=";
      name = "audacity_xdg_paths.patch";
    })
  ];

  # this file *should* be generated by cmake but as of 2.4.2 isn't yet
  postPatch = ''
    touch src/RevisionIdent.h
  '';

  # workaround for a broken cmake. Drop it with a later version to see if it works.
  # https://github.com/NixOS/nixpkgs/issues/94905
  cmakeFlags = lib.optional stdenv.isLinux "-DCMAKE_OSX_ARCHITECTURES=";

  # audacity only looks for ffmpeg at runtime, so we need to link it in manually
  NIX_LDFLAGS = toString [
    # ffmpeg
    "-lavcodec"
    "-lavdevice"
    "-lavfilter"
    "-lavformat"
    "-lavresample"
    "-lavutil"
    "-lpostproc"
    "-lswresample"
    "-lswscale"
  ];

  nativeBuildInputs = [ cmake gettext pkg-config python3 ];

  buildInputs = [
    alsaLib
    expat
    ffmpeg
    file
    flac
    libid3tag
    libjack2
    libmad
    libopus
    libsndfile
    libvorbis
    lilv
    lv2
    pcre
    serd
    sord
    soundtouch
    soxr
    sratom
    suil
    twolame
    wxGTK
    wxGTK.gtk
  ] ++ lib.optionals stdenv.isLinux [
    at-spi2-core
    dbus
    epoxy
    libXdmcp
    libXtst
    libpthreadstubs
    libxkbcommon
    libselinux
    libsepol
    utillinux
  ];

  doCheck = false; # Test fails

  meta = with lib; {
    description = "Sound editor with graphical UI";
    homepage = "https://www.audacityteam.org/";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ lheckemann ];
    platforms = platforms.linux;
{'fraction_non_alphanumeric': 0.1013953488372093, 'fraction_numerical': 0.02455813953488372, 'mean_word_length': 2.801980198019802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '123773', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2067, 'n_words': 468}