nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 cmake,
6 makeWrapper,
7 wrapGAppsHook3,
8 pkg-config,
9 python3,
10 gettext,
11 file,
12 libvorbis,
13 libmad,
14 libjack2,
15 lv2,
16 lilv,
17 mpg123,
18 opusfile,
19 rapidjson,
20 serd,
21 sord,
22 sqlite,
23 sratom,
24 suil,
25 libsndfile,
26 soxr,
27 flac,
28 lame,
29 twolame,
30 expat,
31 libid3tag,
32 libopus,
33 libuuid,
34 ffmpeg,
35 soundtouch,
36 pcre,
37 portaudio, # given up fighting their portaudio.patch?
38 portmidi,
39 linuxHeaders,
40 alsa-lib,
41 at-spi2-core,
42 dbus,
43 libepoxy,
44 libXdmcp,
45 libXtst,
46 libpthreadstubs,
47 libsbsms_2_3_0,
48 libselinux,
49 libsepol,
50 libxkbcommon,
51 util-linux,
52 wavpack,
53 wxGTK32,
54 gtk3,
55 libpng,
56 libjpeg,
57}:
58
59# TODO
60# 1. detach sbsms
61
62stdenv.mkDerivation (finalAttrs: {
63 pname = "audacity";
64 version = "3.7.4";
65
66 src = fetchFromGitHub {
67 owner = "audacity";
68 repo = "audacity";
69 rev = "Audacity-${finalAttrs.version}";
70 hash = "sha256-kESKpIke9Xi4A55i3mUu1JkDjp8voBJBixiAK8pUkKA=";
71 };
72
73 patches = [
74 # Introduced by https://github.com/Tencent/rapidjson/commit/b1c0c2843fcb2aca9ecc650fc035c57ffc13697c#diff-2f1bcf2729ff7c408adb0c2cc2cfa01602bd5646b05b3e4bc7e46b606035d249R21
75 ./rapidjson.patch
76 ];
77
78 postPatch = ''
79 mkdir src/private
80 substituteInPlace scripts/build/macOS/fix_bundle.py \
81 --replace-fail "path.startswith('/usr/lib/')" "path.startswith('${builtins.storeDir}')"
82 ''
83 + lib.optionalString stdenv.hostPlatform.isLinux ''
84 substituteInPlace libraries/lib-files/FileNames.cpp \
85 --replace-fail /usr/include/linux/magic.h ${linuxHeaders}/include/linux/magic.h
86 '';
87
88 nativeBuildInputs = [
89 cmake
90 gettext
91 pkg-config
92 python3
93 makeWrapper
94 wrapGAppsHook3
95 ]
96 ++ lib.optionals stdenv.hostPlatform.isLinux [
97 linuxHeaders
98 ];
99
100 buildInputs = [
101 expat
102 ffmpeg
103 file
104 flac
105 gtk3
106 lame
107 libid3tag
108 libjack2
109 libmad
110 libopus
111 libsbsms_2_3_0
112 libsndfile
113 libvorbis
114 lilv
115 lv2
116 mpg123
117 opusfile
118 pcre
119 portmidi
120 rapidjson
121 serd
122 sord
123 soundtouch
124 soxr
125 sqlite
126 sratom
127 suil
128 twolame
129 portaudio
130 wavpack
131 wxGTK32
132 ]
133 ++ lib.optionals stdenv.hostPlatform.isLinux [
134 alsa-lib # for portaudio
135 at-spi2-core
136 dbus
137 libepoxy
138 libXdmcp
139 libXtst
140 libpthreadstubs
141 libxkbcommon
142 libselinux
143 libsepol
144 libuuid
145 util-linux
146 ]
147 ++ lib.optionals stdenv.hostPlatform.isDarwin [
148 libpng
149 libjpeg
150 ];
151
152 cmakeFlags = [
153 "-DAUDACITY_BUILD_LEVEL=2"
154 "-DAUDACITY_REV_LONG=nixpkgs"
155 "-DAUDACITY_REV_TIME=nixpkgs"
156 "-DDISABLE_DYNAMIC_LOADING_FFMPEG=ON"
157 "-Daudacity_conan_enabled=Off"
158 "-Daudacity_use_ffmpeg=loaded"
159 "-Daudacity_has_vst3=Off"
160 "-Daudacity_has_crashreports=Off"
161
162 # RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/
163 "-DCMAKE_SKIP_BUILD_RPATH=ON"
164
165 # Fix duplicate store paths
166 "-DCMAKE_INSTALL_LIBDIR=lib"
167 ];
168
169 # [ 57%] Generating LightThemeAsCeeCode.h...
170 # ../../utils/image-compiler: error while loading shared libraries:
171 # lib-theme.so: cannot open shared object file: No such file or directory
172 preBuild = ''
173 export LD_LIBRARY_PATH=$PWD/Release/lib/audacity
174 '';
175
176 doCheck = false; # Test fails
177
178 dontWrapGApps = true;
179
180 # Replace audacity's wrapper, to:
181 # - Put it in the right place; it shouldn't be in "$out/audacity"
182 # - Add the ffmpeg dynamic dependency
183 # - Use Xwayland by default on Wayland. See https://github.com/audacity/audacity/pull/5977
184 postFixup =
185 lib.optionalString stdenv.hostPlatform.isLinux ''
186 wrapProgram "$out/bin/audacity" \
187 "''${gappsWrapperArgs[@]}" \
188 --prefix LD_LIBRARY_PATH : "$out/lib/audacity":${lib.makeLibraryPath [ ffmpeg ]} \
189 --suffix AUDACITY_MODULES_PATH : "$out/lib/audacity/modules" \
190 --suffix AUDACITY_PATH : "$out/share/audacity" \
191 --set-default GDK_BACKEND x11
192 ''
193 + lib.optionalString stdenv.hostPlatform.isDarwin ''
194 mkdir -p $out/{Applications,bin}
195 mv $out/Audacity.app $out/Applications/
196 makeWrapper $out/Applications/Audacity.app/Contents/MacOS/Audacity $out/bin/audacity
197 '';
198
199 meta = {
200 description = "Sound editor with graphical UI";
201 mainProgram = "audacity";
202 homepage = "https://www.audacityteam.org";
203 changelog = "https://github.com/audacity/audacity/releases";
204 license = with lib.licenses; [
205 gpl2Plus
206 # Must be GPL3 when building with "technologies that require it,
207 # such as the VST3 audio plugin interface".
208 # https://github.com/audacity/audacity/discussions/2142.
209 gpl3
210 # Documentation.
211 cc-by-30
212 ];
213 maintainers = with lib.maintainers; [
214 veprbl
215 wegank
216 ];
217 platforms = lib.platforms.unix;
218 };
219})