about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/audio/mpg123/default.nix
blob: 94ee6ad53e69fee192455e4f9ad08fa7b2caa5e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ lib
, stdenv
, fetchurl
, makeWrapper
, pkg-config
, libOnly ? false # whether to build only the library
, withAlsa ? stdenv.hostPlatform.isLinux
, alsa-lib
, withPulse ? stdenv.hostPlatform.isLinux
, libpulseaudio
, withCoreAudio ? stdenv.hostPlatform.isDarwin
, AudioUnit
, AudioToolbox
, withJack ? stdenv.hostPlatform.isUnix
, jack
, withConplay ? !stdenv.hostPlatform.isWindows
, perl
}:

assert withConplay -> !libOnly;

stdenv.mkDerivation rec {
  pname = "${lib.optionalString libOnly "lib"}mpg123";
  version = "1.32.3";

  src = fetchurl {
    url = "mirror://sourceforge/mpg123/mpg123-${version}.tar.bz2";
    hash = "sha256-LZkTpX1O6PSXoYLG6CWCYCQJeCpPtIHpif7r9ENYZ7Q=";
  };

  outputs = [ "out" "dev" "man" ] ++ lib.optional withConplay "conplay";

  nativeBuildInputs = lib.optionals (!libOnly) (
    lib.optionals withConplay [ makeWrapper ]
    ++ lib.optionals (withPulse || withJack) [ pkg-config ]
  );

  buildInputs = lib.optionals (!libOnly) (
    lib.optionals withConplay [ perl ]
    ++ lib.optionals withAlsa [ alsa-lib ]
    ++ lib.optionals withPulse [ libpulseaudio ]
    ++ lib.optionals withCoreAudio [ AudioUnit AudioToolbox ]
    ++ lib.optionals withJack [ jack ]
  );

  configureFlags = lib.optionals (!libOnly) [
    "--with-audio=${lib.strings.concatStringsSep "," (
      lib.optional withJack "jack"
      ++ lib.optional withPulse "pulse"
      ++ lib.optional withAlsa "alsa"
      ++ lib.optional withCoreAudio "coreaudio"
      ++ [ "dummy" ]
    )}"
  ] ++ lib.optional (stdenv.hostPlatform ? mpg123) "--with-cpu=${stdenv.hostPlatform.mpg123.cpu}";

  enableParallelBuilding = true;

  postInstall = lib.optionalString withConplay ''
    mkdir -p $conplay/bin
    mv scripts/conplay $conplay/bin/
  '';

  preFixup = lib.optionalString withConplay ''
    patchShebangs $conplay/bin/conplay
  '';

  postFixup = lib.optionalString withConplay ''
    wrapProgram $conplay/bin/conplay \
      --prefix PATH : $out/bin
  '';

  meta = with lib; {
    description = "Fast console MPEG Audio Player and decoder library";
    homepage = "https://mpg123.org";
    license = licenses.lgpl21Only;
    maintainers = with maintainers; [ ftrvxmtrx ];
    platforms = platforms.all;
  };
}