aaxtomp3: use resholve not PATH

Instead of wrapping out binary, we can patch the script to point
directly into /nix/store/. While doing this, we added a few dependencies
we missed and found an osh parsing bug that has been reported upstream.

See oilshell/oil#1446

+64 -23
+49 -23
pkgs/applications/audio/aaxtomp3/default.nix
··· 1 - { coreutils 1 + { bash 2 + , bc 3 + , coreutils 2 4 , fetchFromGitHub 3 5 , ffmpeg 4 6 , findutils 7 + , gawk 5 8 , gnugrep 6 9 , gnused 7 10 , jq 8 11 , lame 9 12 , lib 10 - , makeWrapper 11 13 , mediainfo 12 14 , mp4v2 13 - , stdenv 15 + , ncurses 16 + , resholve 14 17 }: 15 - let 16 - runtimeInputs = [ 17 - coreutils 18 - ffmpeg 19 - findutils 20 - gnugrep 21 - gnused 22 - jq 23 - lame 24 - mediainfo 25 - mp4v2 26 - ]; 27 - in 28 - stdenv.mkDerivation rec { 18 + 19 + resholve.mkDerivation rec { 29 20 pname = "aaxtomp3"; 30 21 version = "1.3"; 31 22 ··· 36 27 hash = "sha256-7a9ZVvobWH/gPxa3cFiPL+vlu8h1Dxtcq0trm3HzlQg="; 37 28 }; 38 29 39 - dontBuild = false; 30 + # use whitespace to show osh arithmetic is not file redirection 31 + # see: https://github.com/oilshell/oil/issues/1446 32 + patches = [./osh.patch]; 40 33 41 - nativeBuildInputs = [ makeWrapper ]; 34 + postPatch = '' 35 + substituteInPlace AAXtoMP3 \ 36 + --replace 'AAXtoMP3' 'aaxtomp3' 37 + substituteInPlace interactiveAAXtoMP3 \ 38 + --replace 'AAXtoMP3' 'aaxtomp3' \ 39 + --replace 'call="./aaxtomp3"' 'call="$AAXTOMP3"' 40 + ''; 42 41 43 42 installPhase = '' 44 - install -Dm755 AAXtoMP3 $out/bin/aaxtomp3 45 - wrapProgram $out/bin/aaxtomp3 --prefix PATH : ${lib.makeBinPath runtimeInputs} 46 - install -Dm755 interactiveAAXtoMP3 $out/bin/interactiveaaxtomp3 47 - wrapProgram $out/bin/interactiveaaxtomp3 --prefix PATH : ${lib.makeBinPath runtimeInputs} 43 + install -Dm 755 AAXtoMP3 $out/bin/aaxtomp3 44 + install -Dm 755 interactiveAAXtoMP3 $out/bin/interactiveaaxtomp3 48 45 ''; 46 + 47 + solutions.default = { 48 + scripts = [ 49 + "bin/aaxtomp3" 50 + "bin/interactiveaaxtomp3" 51 + ]; 52 + interpreter = "${bash}/bin/bash"; 53 + inputs = [ 54 + bc 55 + coreutils 56 + ffmpeg 57 + findutils 58 + gawk 59 + gnugrep 60 + gnused 61 + jq 62 + lame 63 + mediainfo 64 + mp4v2 65 + ncurses 66 + ]; 67 + keep."$call" = true; 68 + fix = { 69 + "$AAXTOMP3" = [ "${placeholder "out"}/bin/aaxtomp3" ]; 70 + "$FIND" = [ "find" ]; 71 + "$GREP" = [ "grep" ]; 72 + "$SED" = [ "sed" ]; 73 + }; 74 + }; 49 75 50 76 meta = with lib; { 51 77 description = "Convert Audible's .aax filetype to MP3, FLAC, M4A, or OPUS";
+15
pkgs/applications/audio/aaxtomp3/osh.patch
··· 1 + diff --git a/AAXtoMP3 b/AAXtoMP3 2 + index 90566ad..71e94da 100755 3 + --- a/AAXtoMP3 4 + +++ b/AAXtoMP3 5 + @@ -200,8 +200,8 @@ progressbar() { 6 + 7 + #draw progressbar with one # for every 5% and blank spaces for the missing part. 8 + progressbar="" 9 + - for (( n=0; n<(percentage/5); n++ )) ; do progressbar="$progressbar#"; done 10 + - for (( n=0; n<(20-(percentage/5)); n++ )) ; do progressbar="$progressbar "; done 11 + + for (( n=0; n< (percentage/5); n++ )) ; do progressbar="$progressbar#"; done 12 + + for (( n=0; n< (20-(percentage/5)); n++ )) ; do progressbar="$progressbar "; done 13 + 14 + #print progressbar 15 + echo -ne "Chapter splitting: |$progressbar| $print_percentage% ($part/$total chapters)\r"