about summary refs log tree commit diff
path: root/pkgs/applications/audio/uade/default.nix
blob: b435bba66b961fca0a416f80d5900ffb567ffd74 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{ lib
, stdenv
, fetchFromGitLab
, python3
, pkg-config
, which
, makeWrapper
, libao
, bencodetools
, sox
, lame
, flac
, vorbis-tools
# https://gitlab.com/uade-music-player/uade/-/issues/38
, withWriteAudio ? !stdenv.hostPlatform.isDarwin
}:

stdenv.mkDerivation rec {
  pname = "uade";
  version = "3.02";

  src = fetchFromGitLab {
    owner = "uade-music-player";
    repo = "uade";
    rev = "uade-${version}";
    hash = "sha256-skPEXBQwyr326zCmZ2jwGxcBoTt3Y/h2hagDeeqbMpw=";
  };

  postPatch = ''
    patchShebangs configure
    substituteInPlace configure \
      --replace 'PYTHON_SETUP_ARGS=""' 'PYTHON_SETUP_ARGS="--prefix=$out"'
    substituteInPlace src/frontends/mod2ogg/mod2ogg2.sh.in \
      --replace '-e stat' '-n stat' \
      --replace '/usr/local' "$out"
    substituteInPlace python/uade/generate_oscilloscope_view.py \
      --replace "default='uade123'" "default='$out/bin/uade123'"
    # https://gitlab.com/uade-music-player/uade/-/issues/37
    substituteInPlace write_audio/Makefile.in \
      --replace 'g++' '${stdenv.cc.targetPrefix}c++'
  '';

  nativeBuildInputs = [
    pkg-config
    which
    makeWrapper
  ] ++ lib.optionals withWriteAudio [
    python3
  ];

  buildInputs = [
    libao
    bencodetools
    sox
    lame
    flac
    vorbis-tools
  ] ++ lib.optionals withWriteAudio [
    (python3.withPackages (p: with p; [
      pillow
      tqdm
      more-itertools
    ]))
  ];

  configureFlags = [
    "--bencode-tools-prefix=${bencodetools}"
    "--with-text-scope"
  ] ++ lib.optionals (!withWriteAudio) [
    "--without-write-audio"
  ];

  enableParallelBuilding = true;

  hardeningDisable = [ "format" ];

  postInstall = ''
    wrapProgram $out/bin/mod2ogg2.sh \
      --prefix PATH : $out/bin:${lib.makeBinPath [ sox lame flac vorbis-tools ]}
    # This is an old script, don't break expectations by renaming it
    ln -s $out/bin/mod2ogg2{.sh,}
  '' + lib.optionalString withWriteAudio ''
    wrapProgram $out/bin/generate_amiga_oscilloscope_view \
      --prefix PYTHONPATH : "$PYTHONPATH:$out/${python3.sitePackages}"
  '';

  meta = with lib; {
    description = "Plays old Amiga tunes through UAE emulation and cloned m68k-assembler Eagleplayer API";
    homepage = "https://zakalwe.fi/uade/";
    # It's a mix of licenses. "GPL", Public Domain, "LGPL", GPL2+, BSD, LGPL21+ and source code with unknown licenses. E.g.
    # - hippel-coso player is "[not] under any Open Source certified license"
    # - infogrames player is disassembled from Andi Silvas player, unknown license
    # Let's make it easy and flag the whole package as unfree.
    license = licenses.unfree;
    maintainers = with maintainers; [ OPNA2608 ];
    mainProgram = "uade123";
    platforms = platforms.unix;
  };
}