about summary refs log tree commit diff
path: root/pkgs/applications/audio/aaxtomp3/default.nix
blob: 59bd228d4751ace9e8abd6819a37f4dab198fc48 (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
{ bash
, bc
, coreutils
, fetchFromGitHub
, ffmpeg
, findutils
, gawk
, gnugrep
, gnused
, jq
, lame
, lib
, mediainfo
, mp4v2
, ncurses
, resholve
}:

resholve.mkDerivation rec {
  pname = "aaxtomp3";
  version = "1.3";

  src = fetchFromGitHub {
    owner = "krumpetpirate";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-7a9ZVvobWH/gPxa3cFiPL+vlu8h1Dxtcq0trm3HzlQg=";
  };

  postPatch = ''
    substituteInPlace AAXtoMP3 \
      --replace 'AAXtoMP3' 'aaxtomp3'
    substituteInPlace interactiveAAXtoMP3 \
      --replace 'AAXtoMP3' 'aaxtomp3' \
      --replace 'call="./aaxtomp3"' 'call="$AAXTOMP3"'
  '';

  installPhase = ''
    install -Dm 755 AAXtoMP3 $out/bin/aaxtomp3
    install -Dm 755 interactiveAAXtoMP3 $out/bin/interactiveaaxtomp3
  '';

  solutions.default = {
    scripts = [
      "bin/aaxtomp3"
      "bin/interactiveaaxtomp3"
    ];
    interpreter = "${bash}/bin/bash";
    inputs = [
      bc
      coreutils
      ffmpeg
      findutils
      gawk
      gnugrep
      gnused
      jq
      lame
      mediainfo
      mp4v2
      ncurses
    ];
    keep."$call" = true;
    fix = {
      "$AAXTOMP3" = [ "${placeholder "out"}/bin/aaxtomp3" ];
      "$FIND" = [ "find" ];
      "$GREP" = [ "grep" ];
      "$SED" = [ "sed" ];
    };
  };

  meta = with lib; {
    description = "Convert Audible's .aax filetype to MP3, FLAC, M4A, or OPUS";
    homepage = "https://krumpetpirate.github.io/AAXtoMP3";
    license = licenses.wtfpl;
    maintainers = with maintainers; [ urandom ];
  };
}