|
| 1 | +{ stdenv, fetchFromGitHub, pkgconfig, symlinkJoin, qmakeHook, diffPlugins |
| 2 | +, qtbase, qtmultimedia, makeQtWrapper |
| 3 | +, taglib, libmediainfo, libzen, libbass }: |
| 4 | + |
| 5 | +let |
| 6 | + version = "2017-05-24"; |
| 7 | + rev = "eed5dc41c849ab29b2dee37d97852fffdb45e390"; |
| 8 | + sha256 = "1ymdgaffazndg9vhh47qqjr5873ld7j066hycp670r08bm519ysg"; |
| 9 | + buildInputs = [ qtbase qtmultimedia taglib libmediainfo libzen libbass ]; |
| 10 | + |
| 11 | + plugins = [ |
| 12 | + "albumartex" |
| 13 | + "amazon" |
| 14 | + "audiotag" |
| 15 | + "cleanup" |
| 16 | + "freecovers" |
| 17 | + "lyric" |
| 18 | + "preparatory" |
| 19 | + "rename" |
| 20 | + ]; |
| 21 | + |
| 22 | + patchedSrc = |
| 23 | + let src = fetchFromGitHub { |
| 24 | + owner = "UltraStar-Deluxe"; |
| 25 | + repo = "UltraStar-Manager"; |
| 26 | + inherit rev sha256; |
| 27 | + }; |
| 28 | + in stdenv.mkDerivation { |
| 29 | + name = "${src.name}-patched"; |
| 30 | + inherit src; |
| 31 | + phases = [ "unpackPhase" "patchPhase" ]; |
| 32 | + |
| 33 | + patchPhase = with stdenv.lib; '' |
| 34 | + # we don’t want prebuild binaries checked into version control! |
| 35 | + rm -rf lib include |
| 36 | +
|
| 37 | + # fix up main project file |
| 38 | + sed -e 's|-L.*unix.*lbass.*$|-lbass|' \ |
| 39 | + -e "/QMAKE_POST_LINK/d" \ |
| 40 | + -e "s|../include/bass|${getLib libbass}/include|g" \ |
| 41 | + -e "s|../include/taglib|${getLib taglib}/include|g" \ |
| 42 | + -e "s|../include/mediainfo|${getLib libmediainfo}/include|g" \ |
| 43 | + -i src/UltraStar-Manager.pro |
| 44 | +
|
| 45 | + # if more plugins start depending on ../../../include, |
| 46 | + # it should be abstracted out for all .pro files |
| 47 | + sed -e "s|../../../include/taglib|${getLib taglib}/include/taglib|g" \ |
| 48 | + -i src/plugins/audiotag/audiotag.pro |
| 49 | +
|
| 50 | + mkdir $out |
| 51 | + mv * $out |
| 52 | + ''; |
| 53 | + }; |
| 54 | + |
| 55 | + patchApplicationPath = file: path: '' |
| 56 | + sed -e "s|QCore.*applicationDirPath()|QString(\"${path}\")|" -i "${file}" |
| 57 | + ''; |
| 58 | + |
| 59 | + buildPlugin = name: stdenv.mkDerivation { |
| 60 | + name = "ultrastar-manager-${name}-plugin-${version}"; |
| 61 | + src = patchedSrc; |
| 62 | + |
| 63 | + buildInputs = [ qmakeHook ] ++ buildInputs; |
| 64 | + |
| 65 | + postPatch = '' |
| 66 | + sed -e "s|DESTDIR = .*$|DESTDIR = $out|" \ |
| 67 | + -i src/plugins/${name}/${name}.pro |
| 68 | +
|
| 69 | + # plugins use the application’s binary folder (wtf) |
| 70 | + for f in $(grep -lr "QCoreApplication::applicationDirPath" src/plugins); do |
| 71 | + ${patchApplicationPath "$f" "\$out"} |
| 72 | + done |
| 73 | +
|
| 74 | + ''; |
| 75 | + preConfigure = '' |
| 76 | + cd src/plugins/${name} |
| 77 | + ''; |
| 78 | + }; |
| 79 | + |
| 80 | + builtPlugins = |
| 81 | + symlinkJoin { |
| 82 | + name = "ultrastar-manager-plugins-${version}"; |
| 83 | + paths = map buildPlugin plugins; |
| 84 | + }; |
| 85 | + |
| 86 | +in stdenv.mkDerivation { |
| 87 | + name = "ultrastar-manager-${version}"; |
| 88 | + src = patchedSrc; |
| 89 | + |
| 90 | + postPatch = '' |
| 91 | + sed -e "s|DESTDIR =.*$|DESTDIR = $out/bin|" \ |
| 92 | + -i src/UltraStar-Manager.pro |
| 93 | + # patch plugin manager to point to the collected plugin folder |
| 94 | + ${patchApplicationPath "src/plugins/QUPluginManager.cpp" builtPlugins} |
| 95 | + ''; |
| 96 | + |
| 97 | + buildPhase = '' |
| 98 | + find -path './src/plugins/*' -prune -type d -print0 \ |
| 99 | + | xargs -0 -i'{}' basename '{}' \ |
| 100 | + | sed -e '/shared/d' \ |
| 101 | + > found_plugins |
| 102 | + ${diffPlugins plugins "found_plugins"} |
| 103 | +
|
| 104 | + cd src && qmake && make |
| 105 | + ''; |
| 106 | + |
| 107 | + # is not installPhase so that qt post hooks can run |
| 108 | + preInstall = '' |
| 109 | + make install |
| 110 | + ''; |
| 111 | + |
| 112 | + nativeBuildInputs = [ makeQtWrapper pkgconfig ]; |
| 113 | + inherit buildInputs; |
| 114 | + |
| 115 | + meta = with stdenv.lib; { |
| 116 | + description = "Ultrastar karaoke song manager"; |
| 117 | + homepage = https://github.com/UltraStar-Deluxe/UltraStar-Manager; |
| 118 | + license = licenses.gpl2; |
| 119 | + maintainers = with maintainers; [ profpatsch ]; |
| 120 | + }; |
| 121 | +} |
0 commit comments