nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 wrapGAppsHook3,
8 pkg-config,
9 ninja,
10 alsa-lib,
11 alsa-plugins,
12 freetype,
13 libjack2,
14 lame,
15 libogg,
16 libpulseaudio,
17 libsndfile,
18 libvorbis,
19 portaudio,
20 portmidi,
21 flac,
22 libopusenc,
23 libopus,
24 tinyxml-2,
25 kdePackages,
26 nixosTests,
27}:
28
29stdenv.mkDerivation (finalAttrs: {
30 pname = "musescore";
31 version = "4.6.5";
32
33 src = fetchFromGitHub {
34 owner = "musescore";
35 repo = "MuseScore";
36 tag = "v${finalAttrs.version}";
37 hash = "sha256-lfgf09gLeoiXc0xsJvvKAnSJUjy/L2Fdis/9SNjb1KM=";
38 };
39
40 cmakeFlags = [
41 "-DMUSE_APP_BUILD_MODE=release"
42 # Disable the build and usage of the `/bin/crashpad_handler` utility - it's
43 # not useful on NixOS, see:
44 # https://github.com/musescore/MuseScore/issues/15571
45 "-DMUSE_MODULE_DIAGNOSTICS_CRASHPAD_CLIENT=OFF"
46 # Use our versions of system libraries
47 "-DMUE_COMPILE_USE_SYSTEM_FREETYPE=ON"
48 "-DMUE_COMPILE_USE_SYSTEM_HARFBUZZ=ON"
49 "-DMUE_COMPILE_USE_SYSTEM_TINYXML=ON"
50 # Implies also -DMUE_COMPILE_USE_SYSTEM_OPUS=ON
51 "-DMUE_COMPILE_USE_SYSTEM_OPUSENC=ON"
52 "-DMUE_COMPILE_USE_SYSTEM_FLAC=ON"
53 # Don't bundle qt qml files, relevant really only for darwin, but we set
54 # this for all platforms anyway.
55 "-DMUE_COMPILE_INSTALL_QTQML_FILES=OFF"
56 # Don't build unit tests unless we are going to run them.
57 (lib.cmakeBool "MUSE_ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
58 ];
59
60 qtWrapperArgs = [
61 # MuseScore JACK backend loads libjack at runtime.
62 "--prefix ${lib.optionalString stdenv.hostPlatform.isDarwin "DY"}LD_LIBRARY_PATH : ${
63 lib.makeLibraryPath [ libjack2 ]
64 }"
65 ]
66 ++ lib.optionals (stdenv.hostPlatform.isLinux) [
67 "--set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib"
68 ]
69 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
70 # There are some issues with using the wayland backend, see:
71 # https://musescore.org/en/node/321936
72 "--set-default QT_QPA_PLATFORM xcb"
73 ];
74
75 preFixup = ''
76 qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
77 '';
78
79 dontWrapGApps = true;
80
81 nativeBuildInputs = [
82 kdePackages.wrapQtAppsHook
83 cmake
84 kdePackages.qttools
85 pkg-config
86 ninja
87 ]
88 ++ lib.optionals stdenv.hostPlatform.isLinux [
89 # Since https://github.com/musescore/MuseScore/pull/13847/commits/685ac998
90 # GTK3 is needed for file dialogs. Fixes crash with No GSettings schemas error.
91 wrapGAppsHook3
92 ];
93
94 buildInputs = [
95 libjack2
96 freetype
97 lame
98 libogg
99 libpulseaudio
100 libsndfile
101 libvorbis
102 portaudio
103 portmidi
104 flac
105 libopusenc
106 libopus
107 tinyxml-2
108 kdePackages.qtbase
109 kdePackages.qtdeclarative
110 kdePackages.qt5compat
111 kdePackages.qtsvg
112 kdePackages.qtscxml
113 kdePackages.qtnetworkauth
114 ]
115 ++ lib.optionals stdenv.hostPlatform.isLinux [
116 alsa-lib
117 kdePackages.qtwayland
118 ];
119
120 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
121 mkdir -p "$out/Applications"
122 mv "$out/mscore.app" "$out/Applications/mscore.app"
123 mkdir -p $out/bin
124 ln -s $out/Applications/mscore.app/Contents/MacOS/mscore $out/bin/mscore
125 '';
126
127 # muse-sounds-manager installs Muse Sounds sampler libMuseSamplerCoreLib.so.
128 # It requires that argv0 of the calling process ends with "/mscore" or "/MuseScore-4".
129 # We need to ensure this in two cases:
130 #
131 # 1) when the user invokes MuseScore as "mscore" on the command line or from
132 # the .desktop file, and the normal argv0 is "mscore" (no "/");
133 # 2) when MuseScore invokes itself via File -> New, and the normal argv0 is
134 # the target of /proc/self/exe, which in Nixpkgs was "{...}/.mscore-wrapped"
135 #
136 # In order to achieve (2) we install the final binary as $out/libexec/mscore, and
137 # in order to achieve (1) we use makeWrapper without --inherit-argv0.
138 #
139 # wrapQtAppsHook uses wrapQtApp -> wrapProgram -> makeBinaryWrapper --inherit-argv0
140 # so we disable it and explicitly use makeQtWrapper.
141 #
142 # TODO: check if something like this is also needed for macOS.
143 dontWrapQtApps = stdenv.hostPlatform.isLinux;
144 postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
145 mkdir -p $out/libexec
146 mv $out/bin/mscore $out/libexec
147 makeQtWrapper $out/libexec/mscore $out/bin/mscore
148 '';
149
150 # Don't run bundled upstreams tests, as they require a running X window system.
151 doCheck = false;
152
153 passthru.tests = nixosTests.musescore;
154
155 meta = {
156 description = "Music notation and composition software";
157 homepage = "https://musescore.org/";
158 license = lib.licenses.gpl3Only;
159 maintainers = with lib.maintainers; [
160 vandenoever
161 doronbehar
162 sarunint
163 ];
164 mainProgram = "mscore";
165 platforms = lib.platforms.unix;
166 };
167})