Unverified Commit ea2a73f1 authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

audacity: move to by-name, format and refactor (#348861)

parents f30a0466 0c8d09f2
Loading
Loading
Loading
Loading
+224 −0
Original line number Diff line number Diff line
{ stdenv
, lib
, fetchFromGitHub
, cmake
, makeWrapper
, wrapGAppsHook3
, pkg-config
, python3
, gettext
, file
, libvorbis
, libmad
, libjack2
, lv2
, lilv
, mpg123
, opusfile
, rapidjson
, serd
, sord
, sqlite
, sratom
, suil
, libsndfile
, soxr
, flac
, lame
, twolame
, expat
, libid3tag
, libopus
, libuuid
, ffmpeg
, soundtouch
, pcre
, portaudio # given up fighting their portaudio.patch?
, portmidi
, linuxHeaders
, alsa-lib
, at-spi2-core
, dbus
, libepoxy
, libXdmcp
, libXtst
, libpthreadstubs
, libsbsms_2_3_0
, libselinux
, libsepol
, libxkbcommon
, util-linux
, wavpack
, wxGTK32
, gtk3
, libpng
, libjpeg
, AppKit
, CoreAudioKit
{
  stdenv,
  lib,
  fetchFromGitHub,
  cmake,
  makeWrapper,
  wrapGAppsHook3,
  pkg-config,
  python3,
  gettext,
  file,
  libvorbis,
  libmad,
  libjack2,
  lv2,
  lilv,
  mpg123,
  opusfile,
  rapidjson,
  serd,
  sord,
  sqlite,
  sratom,
  suil,
  libsndfile,
  soxr,
  flac,
  lame,
  twolame,
  expat,
  libid3tag,
  libopus,
  libuuid,
  ffmpeg,
  soundtouch,
  pcre,
  portaudio, # given up fighting their portaudio.patch?
  portmidi,
  linuxHeaders,
  alsa-lib,
  at-spi2-core,
  dbus,
  libepoxy,
  libXdmcp,
  libXtst,
  libpthreadstubs,
  libsbsms_2_3_0,
  libselinux,
  libsepol,
  libxkbcommon,
  util-linux,
  wavpack,
  wxGTK32,
  gtk3,
  libpng,
  libjpeg,
  darwin,
}:

# TODO
# 1. detach sbsms

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "audacity";
  version = "3.6.4";

  src = fetchFromGitHub {
    owner = "audacity";
    repo = "audacity";
    rev = "Audacity-${version}";
    rev = "Audacity-${finalAttrs.version}";
    hash = "sha256-72k79UFxhk8JUCnMzbU9lZ0Ua3Ui41EkhPGSnGkf9mE=";
  };

  postPatch = ''
  postPatch =
    ''
      mkdir src/private
      substituteInPlace scripts/build/macOS/fix_bundle.py \
        --replace "path.startswith('/usr/lib/')" "path.startswith('${builtins.storeDir}')"
  '' + lib.optionalString stdenv.hostPlatform.isLinux ''
    ''
    + lib.optionalString stdenv.hostPlatform.isLinux ''
      substituteInPlace libraries/lib-files/FileNames.cpp \
        --replace /usr/include/linux/magic.h ${linuxHeaders}/include/linux/magic.h
  '' + lib.optionalString (stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11.0") ''
    ''
    +
      lib.optionalString
        (stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11.0")
        ''
          sed -z -i "s/NSAppearanceName.*systemAppearance//" src/AudacityApp.mm
        '';

  nativeBuildInputs = [
  nativeBuildInputs =
    [
      cmake
      gettext
      pkg-config
      python3
      makeWrapper
      wrapGAppsHook3
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      linuxHeaders
    ];

  buildInputs = [
  buildInputs =
    [
      expat
      ffmpeg
      file
@@ -125,7 +134,8 @@ stdenv.mkDerivation rec {
      portaudio
      wavpack
      wxGTK32
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      alsa-lib # for portaudio
      at-spi2-core
      dbus
@@ -138,9 +148,10 @@ stdenv.mkDerivation rec {
      libsepol
      libuuid
      util-linux
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
    AppKit
    CoreAudioKit # for portaudio
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      darwin.apple_sdk.frameworks.AppKit
      darwin.apple_sdk.frameworks.CoreAudioKit # for portaudio
      libpng
      libjpeg
    ];
@@ -176,24 +187,26 @@ stdenv.mkDerivation rec {
  # Replace audacity's wrapper, to:
  # - put it in the right place, it shouldn't be in "$out/audacity"
  # - Add the ffmpeg dynamic dependency
  postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
  postFixup =
    lib.optionalString stdenv.hostPlatform.isLinux ''
      wrapProgram "$out/bin/audacity" \
        "''${gappsWrapperArgs[@]}" \
        --prefix LD_LIBRARY_PATH : "$out/lib/audacity":${lib.makeLibraryPath [ ffmpeg ]} \
        --suffix AUDACITY_MODULES_PATH : "$out/lib/audacity/modules" \
        --suffix AUDACITY_PATH : "$out/share/audacity"
  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      mkdir -p $out/{Applications,bin}
      mv $out/Audacity.app $out/Applications/
      makeWrapper $out/Applications/Audacity.app/Contents/MacOS/Audacity $out/bin/audacity
    '';

  meta = with lib; {
  meta = {
    description = "Sound editor with graphical UI";
    mainProgram = "audacity";
    homepage = "https://www.audacityteam.org";
    changelog = "https://github.com/audacity/audacity/releases";
    license = with licenses; [
    license = with lib.licenses; [
      gpl2Plus
      # Must be GPL3 when building with "technologies that require it,
      # such as the VST3 audio plugin interface".
@@ -202,7 +215,10 @@ stdenv.mkDerivation rec {
      # Documentation.
      cc-by-30
    ];
    maintainers = with maintainers; [ veprbl wegank ];
    platforms = platforms.unix;
    maintainers = with lib.maintainers; [
      veprbl
      wegank
    ];
    platforms = lib.platforms.unix;
  };
}
})
+0 −4
Original line number Diff line number Diff line
@@ -28122,10 +28122,6 @@ with pkgs;
    audacious = audacious.override { audacious-plugins = null; };
  };
  audacity = callPackage ../applications/audio/audacity {
    inherit (darwin.apple_sdk.frameworks) AppKit CoreAudioKit;
  };
  audio-recorder = callPackage ../applications/audio/audio-recorder { };
  auto-multiple-choice = callPackage ../applications/misc/auto-multiple-choice { };