Skip to content

Commit 79dd4de

Browse files
Profpatschqknight
authored andcommittedJun 14, 2017
Ultrastar (#26524)
* ultrastardx-beta: init at 1.3.5 * libbass, libbass_fx: init at 24 * ultrastar-creator: init at 2017-04-12 * buildSupport/plugins.nix: add diffPlugins Helper function to compare expected plugin lists to the found plugins. * ultrastar-manager: init at 2017-05-24 The plugins are built in their own derivations, speeding up (re-)compilation. The `diffPlugins` function from `beets` is reused to test for changes in the plugin list on updates. * beets: switch to diffPlugins The function is basically just extracted for better reusability.
1 parent f6fbbab commit 79dd4de

File tree

8 files changed

+315
-10
lines changed

8 files changed

+315
-10
lines changed
 

‎pkgs/build-support/plugins.nix

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{ stdenv }:
2+
# helper functions for packaging programs with plugin systems
3+
{
4+
5+
/* Takes a list of expected plugin names
6+
* and compares it to the found plugins given in the file,
7+
* one plugin per line.
8+
* If the lists differ, the build fails with a nice message.
9+
*
10+
* This is helpful to ensure maintainers don’t miss
11+
* the addition or removal of a plugin.
12+
*/
13+
diffPlugins = expectedPlugins: foundPluginsFilePath: ''
14+
# sort both lists first
15+
plugins_expected=$(mktemp)
16+
(${stdenv.lib.concatMapStrings (s: "echo \"${s}\";") expectedPlugins}) \
17+
| sort -u > "$plugins_expected"
18+
plugins_found=$(mktemp)
19+
sort -u "${foundPluginsFilePath}" > "$plugins_found"
20+
21+
if ! mismatches="$(diff -y "$plugins_expected" "$plugins_found")"; then
22+
echo "The the list of expected plugins (left side) doesn't match" \
23+
"the list of plugins we found (right side):" >&2
24+
echo "$mismatches" >&2
25+
exit 1
26+
fi
27+
'';
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{ stdenv, unzip, fetchurl, writeText }:
2+
3+
let
4+
version = "24";
5+
6+
allBass = {
7+
bass = {
8+
h = "bass.h";
9+
so = {
10+
i686_linux = "libbass.so";
11+
x86_64-linux = "x64/libbass.so";
12+
};
13+
urlpath = "bass${version}-linux.zip";
14+
sha256 = "1a2z9isabkymz7qmkgklbjpj2wxkvv1cngfp9aj0c9178v97pjd7";
15+
};
16+
17+
bass_fx = {
18+
h = "C/bass_fx.h";
19+
so = {
20+
i686_linux = "libbass_fx.so";
21+
x86_64-linux = "x64/libbass_fx.so";
22+
};
23+
urlpath = "z/0/bass_fx${version}-linux.zip";
24+
sha256 = "0j1cbq88j3vnqf2bibcqnfhciz904w48ldgycyh9d8954hwyg22m";
25+
};
26+
};
27+
28+
dropBass = name: bass: stdenv.mkDerivation {
29+
name = "lib${name}-${version}";
30+
31+
src = fetchurl {
32+
url = "https://www.un4seen.com/files/${bass.urlpath}";
33+
inherit (bass) sha256;
34+
};
35+
unpackCmd = ''
36+
mkdir out
37+
${unzip}/bin/unzip $curSrc -d out
38+
'';
39+
40+
lpropagatedBuildInputs = [ unzip ];
41+
dontBuild = true;
42+
installPhase =
43+
let so =
44+
if bass.so ? ${stdenv.system} then bass.so.${stdenv.system}
45+
else abort "${name} not packaged for ${stdenv.system} (yet).";
46+
in ''
47+
mkdir -p $out/{lib,include}
48+
install -m644 -t $out/lib/ ${so}
49+
install -m644 -t $out/include/ ${bass.h}
50+
'';
51+
52+
meta = with stdenv.lib; {
53+
description = "Shareware audio library";
54+
homepage = https://www.un4seen.com/;
55+
license = licenses.unfreeRedistributable;
56+
};
57+
};
58+
59+
in stdenv.lib.mapAttrs dropBass allBass
File renamed without changes.

‎pkgs/games/ultrastardx/1.3-beta.nix

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{ stdenv, autoreconfHook, fetchFromGitHub, pkgconfig
2+
, lua, fpc, pcre, portaudio, freetype, libpng
3+
, SDL2, SDL2_image, SDL2_gfx, SDL2_mixer, SDL2_net, SDL2_ttf
4+
, ffmpeg, sqlite, zlib, libX11, mesa }:
5+
6+
let
7+
sharedLibs = [
8+
pcre portaudio freetype
9+
SDL2 SDL2_image SDL2_gfx SDL2_mixer SDL2_net SDL2_ttf
10+
sqlite lua zlib libX11 mesa ffmpeg
11+
];
12+
13+
in stdenv.mkDerivation rec {
14+
name = "ultrastardx-${version}";
15+
version = "1.3.5-beta";
16+
src = fetchFromGitHub {
17+
owner = "UltraStar-Deluxe";
18+
repo = "USDX";
19+
rev = "v${version}";
20+
sha256 = "0qp64qsj29a08cbv3i52jm1w2pcklw6ya5sniycs24zxggza5pkn";
21+
};
22+
23+
buildInputs = [
24+
pkgconfig autoreconfHook
25+
fpc libpng
26+
] ++ sharedLibs;
27+
28+
postPatch = ''
29+
# autoconf substitutes strange things otherwise
30+
substituteInPlace src/config.inc.in \
31+
--subst-var-by libpcre_LIBNAME libpcre.so.1
32+
'';
33+
34+
preBuild = with stdenv.lib;
35+
let items = concatMapStringsSep " " (x: "-rpath ${getLib x}/lib") sharedLibs;
36+
in ''
37+
export NIX_LDFLAGS="$NIX_LDFLAGS ${items}"
38+
'';
39+
40+
# dlopened libgcc requires the rpath not to be shrinked
41+
dontPatchELF = true;
42+
43+
meta = with stdenv.lib; {
44+
homepage = http://ultrastardx.sourceforge.net/;
45+
description = "Free and open source karaoke game";
46+
license = licenses.gpl2Plus;
47+
maintainers = with maintainers; [ profpatsch ];
48+
};
49+
}

‎pkgs/tools/audio/beets/default.nix

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, fetchFromGitHub, writeScript, glibcLocales
1+
{ stdenv, fetchFromGitHub, writeScript, glibcLocales, diffPlugins
22
, pythonPackages, imagemagick, gobjectIntrospection, gst_all_1
33

44
, enableAcousticbrainz ? true
@@ -158,20 +158,13 @@ in pythonPackages.buildPythonApplication rec {
158158
doCheck = true;
159159

160160
preCheck = ''
161-
(${concatMapStrings (s: "echo \"${s}\";") allPlugins}) \
162-
| sort -u > plugins_defined
163161
find beetsplug -mindepth 1 \
164162
\! -path 'beetsplug/__init__.py' -a \
165163
\( -name '*.py' -o -path 'beetsplug/*/__init__.py' \) -print \
166164
| sed -n -re 's|^beetsplug/([^/.]+).*|\1|p' \
167165
| sort -u > plugins_available
168166
169-
if ! mismatches="$(diff -y plugins_defined plugins_available)"; then
170-
echo "The the list of defined plugins (left side) doesn't match" \
171-
"the list of available plugins (right side):" >&2
172-
echo "$mismatches" >&2
173-
exit 1
174-
fi
167+
${diffPlugins allPlugins "plugins_available"}
175168
'';
176169

177170
checkPhase = ''
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{ stdenv, fetchFromGitHub
2+
, qmakeHook, qtbase, makeQtWrapper
3+
, pkgconfig, taglib, libbass, libbass_fx }:
4+
5+
stdenv.mkDerivation rec {
6+
name = "ultrastar-creator-${version}";
7+
version = "2017-04-12";
8+
9+
src = fetchFromGitHub {
10+
owner = "UltraStar-Deluxe";
11+
repo = "UltraStar-Creator";
12+
rev = "ac519a003f8283bfbe5e2d8e9cdff3a3faf97001";
13+
sha256 = "00idr8a178gvmylq722n13bli59kpxlsy5d8hlplqn7fih48mnzi";
14+
};
15+
16+
postPatch = with stdenv.lib; ''
17+
# we don’t want prebuild binaries checked into version control!
18+
rm -rf lib include
19+
sed -e "s|DESTDIR =.*$|DESTDIR = $out/bin|" \
20+
-e 's|-L".*unix"||' \
21+
-e "/QMAKE_POST_LINK/d" \
22+
-e "s|../include/bass|${getLib libbass}/include|g" \
23+
-e "s|../include/bass_fx|${getLib libbass_fx}/include|g" \
24+
-e "s|../include/taglib|${getLib taglib}/include|g" \
25+
-i src/UltraStar-Creator.pro
26+
'';
27+
28+
preConfigure = ''
29+
cd src
30+
'';
31+
32+
nativeBuildInputs = [ qmakeHook makeQtWrapper pkgconfig ];
33+
buildInputs = [ qtbase taglib libbass libbass_fx ];
34+
35+
meta = with stdenv.lib; {
36+
description = "Ultrastar karaoke song creation tool";
37+
homepage = https://github.com/UltraStar-Deluxe/UltraStar-Creator;
38+
license = licenses.gpl2;
39+
maintainers = with maintainers; [ profpatsch ];
40+
};
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
}

‎pkgs/top-level/all-packages.nix

+14-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ with pkgs;
9898
inherit (haskellPackages) dhall-nix;
9999
};
100100

101+
diffPlugins = (callPackage ../build-support/plugins.nix {}).diffPlugins;
102+
101103
dockerTools = callPackage ../build-support/docker { };
102104

103105
docker_compose = pythonPackages.docker_compose;
@@ -8325,6 +8327,9 @@ with pkgs;
83258327
inherit (ocamlPackages_4_02) bap ocaml findlib ctypes;
83268328
};
83278329

8330+
libbass = (callPackage ../development/libraries/audio/libbass { }).bass;
8331+
libbass_fx = (callPackage ../development/libraries/audio/libbass { }).bass_fx;
8332+
83288333
libbluedevil = callPackage ../development/libraries/libbluedevil { };
83298334

83308335
libbdplus = callPackage ../development/libraries/libbdplus { };
@@ -17327,7 +17332,15 @@ with pkgs;
1732717332

1732817333
ultimatestunts = callPackage ../games/ultimatestunts { };
1732917334

17330-
ultrastardx = callPackage ../games/ultrastardx {
17335+
ultrastar-creator = libsForQt5.callPackage ../tools/misc/ultrastar-creator { };
17336+
17337+
ultrastar-manager = libsForQt5.callPackage ../tools/misc/ultrastar-manager { };
17338+
17339+
ultrastardx = callPackage ../games/ultrastardx/1.1.nix {
17340+
ffmpeg = ffmpeg_0;
17341+
lua = lua5;
17342+
};
17343+
ultrastardx-beta = callPackage ../games/ultrastardx/1.3-beta.nix {
1733117344
ffmpeg = ffmpeg_0;
1733217345
lua = lua5;
1733317346
};

0 commit comments

Comments
 (0)
Please sign in to comment.