nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromBitbucket,
5 nix-update-script,
6 boost,
7 zlib,
8 # File backends (for decoding and encoding)
9 withMp3 ? true,
10 lame,
11 withOgg ? true,
12 libvorbis,
13 withFlac ? true,
14 flac,
15 # Audio backends (for playback)
16 withOpenal ? false,
17 openal,
18 withSDL ? false,
19 SDL,
20 withOss ? false,
21 withAlsa ? stdenv.hostPlatform.isLinux,
22 alsa-lib,
23 withPulse ? stdenv.hostPlatform.isLinux,
24 libpulseaudio,
25 # GUI audio player
26 withQt ? true,
27 qt5,
28 zip,
29 makeDesktopItem,
30 copyDesktopItems,
31}:
32let
33 dlopenBuildInputs =
34 [ ]
35 ++ lib.optional withMp3 lame
36 ++ lib.optional withOgg libvorbis
37 ++ lib.optional withFlac flac
38 ++ lib.optional withOpenal openal
39 ++ lib.optional withSDL SDL
40 ++ lib.optional withAlsa alsa-lib
41 ++ lib.optional withPulse libpulseaudio;
42 supportWayland = (!stdenv.hostPlatform.isDarwin);
43 platformName = "linux";
44 staticBuildInputs = [
45 boost
46 zlib
47 ]
48 ++ lib.optional withQt (if (supportWayland) then qt5.qtwayland else qt5.qtbase);
49in
50stdenv.mkDerivation rec {
51 pname = "zxtune";
52 version = "5100";
53
54 outputs = [ "out" ];
55
56 src = fetchFromBitbucket {
57 owner = "zxtune";
58 repo = "zxtune";
59 rev = "r${version}";
60 hash = "sha256-SNHnpLAbiHCo11V090EY/vLH4seoZWpMHMMBLGkr88E=";
61 };
62
63 passthru.updateScript = nix-update-script {
64 extraArgs = [
65 "--version-regex"
66 "r([0-9]+)"
67 ];
68 };
69
70 strictDeps = true;
71
72 nativeBuildInputs = lib.optionals withQt [
73 zip
74 qt5.wrapQtAppsHook
75 copyDesktopItems
76 ];
77
78 buildInputs = staticBuildInputs ++ dlopenBuildInputs;
79
80 patches = [
81 ./disable_updates.patch
82 ];
83
84 # Fix use of old OpenAL header path
85 postPatch = ''
86 substituteInPlace src/sound/backends/gates/openal_api.h \
87 --replace "#include <OpenAL/" "#include <AL/"
88 '';
89
90 buildPhase =
91 let
92 setOptionalSupport = name: var: "support_${name}=" + (if (var) then "1" else "");
93 makeOptsCommon = [
94 ''-j$NIX_BUILD_CORES''
95 ''root.version=${src.rev}''
96 ''system.zlib=1''
97 ''platform=${platformName}''
98 ''includes.dirs.${platformName}="${lib.makeSearchPathOutput "dev" "include" buildInputs}"''
99 ''libraries.dirs.${platformName}="${lib.makeLibraryPath staticBuildInputs}"''
100 ''ld_flags="-Wl,-rpath=\"${lib.makeLibraryPath dlopenBuildInputs}\""''
101 (setOptionalSupport "mp3" withMp3)
102 (setOptionalSupport "ogg" withOgg)
103 (setOptionalSupport "flac" withFlac)
104 (setOptionalSupport "openal" withOpenal)
105 (setOptionalSupport "sdl" withSDL)
106 (setOptionalSupport "oss" withOss)
107 (setOptionalSupport "alsa" withAlsa)
108 (setOptionalSupport "pulseaudio" withPulse)
109 ];
110 makeOptsQt = [
111 ''tools.uic=${qt5.qtbase.dev}/bin/uic''
112 ''tools.moc=${qt5.qtbase.dev}/bin/moc''
113 ''tools.rcc=${qt5.qtbase.dev}/bin/rcc''
114 ];
115 in
116 ''
117 runHook preBuild
118 make ${builtins.toString makeOptsCommon} -C apps/xtractor
119 make ${builtins.toString makeOptsCommon} -C apps/zxtune123
120 ''
121 + lib.optionalString withQt ''
122 make ${builtins.toString (makeOptsCommon ++ makeOptsQt)} -C apps/zxtune-qt
123 ''
124 + ''
125 runHook postBuild
126 '';
127
128 # Libs from dlopenBuildInputs are found with dlopen. Do not shrink rpath. Can
129 # check output of 'out/bin/zxtune123 --list-backends' to verify all plugins
130 # load ("Status: Available" or "Status: Failed to load dynamic library...").
131 dontPatchELF = true;
132
133 installPhase = ''
134 runHook preInstall
135 install -Dm755 bin/linux/release/xtractor -t $out/bin
136 install -Dm755 bin/linux/release/zxtune123 -t $out/bin
137 ''
138 + lib.optionalString withQt ''
139 install -Dm755 bin/linux/release/zxtune-qt -t $out/bin
140 install -Dm755 apps/zxtune-qt/res/theme_default/zxtune.png -t $out/share/icons/hicolor/48x48/apps
141 ''
142 + ''
143 runHook postInstall
144 '';
145
146 # Only wrap the gui
147 dontWrapQtApps = true;
148 preFixup = lib.optionalString withQt ''
149 wrapQtApp "$out/bin/zxtune-qt"
150 '';
151
152 desktopItems = lib.optionals withQt [
153 (makeDesktopItem {
154 name = "ZXTune";
155 exec = "zxtune-qt";
156 icon = "zxtune";
157 desktopName = "ZXTune";
158 genericName = "ZXTune";
159 comment = meta.description;
160 categories = [ "Audio" ];
161 type = "Application";
162 })
163 ];
164
165 meta = with lib; {
166 description = "Crossplatform chiptunes player";
167 longDescription = ''
168 Chiptune music player with truly extensive format support. Supported
169 formats/chips include AY/YM, ZX Spectrum, PC, Amiga, Atari, Acorn, Philips
170 SAA1099, MOS6581 (Commodore 64), NES, SNES, GameBoy, Atari, TurboGrafX,
171 Nintendo DS, Sega Master System, and more. Powered by vgmstream, OpenMPT,
172 sidplay, and many other libraries.
173 '';
174 homepage = "https://zxtune.bitbucket.io/";
175 license = licenses.gpl3;
176 # zxtune supports mac and windows, but more work will be needed to
177 # integrate with the custom make system (see platformName above)
178 platforms = platforms.linux;
179 maintainers = with maintainers; [ EBADBEEF ];
180 mainProgram = if withQt then "zxtune-qt" else "zxtune123";
181 };
182}