38 stdenv.mkDerivation (finalAttrs: {
42 src = fetchFromGitHub {
45 rev = "v${finalAttrs.version}";
46 sha256 = "sha256-/1kAgzmSbnuCqd6YxbaYW2+gE0Gvy373y5VfUK4OVzI=";
50 "-DMUSE_APP_BUILD_MODE=release"
51 # Disable the build and usage of the `/bin/crashpad_handler` utility - it's
52 # not useful on NixOS, see:
53 # https://github.com/musescore/MuseScore/issues/15571
54 "-DMUSE_MODULE_DIAGNOSTICS_CRASHPAD_CLIENT=OFF"
55 # Use our versions of system libraries
56 "-DMUE_COMPILE_USE_SYSTEM_FREETYPE=ON"
57 "-DMUE_COMPILE_USE_SYSTEM_HARFBUZZ=ON"
58 "-DMUE_COMPILE_USE_SYSTEM_TINYXML=ON"
59 # Implies also -DMUE_COMPILE_USE_SYSTEM_OPUS=ON
60 "-DMUE_COMPILE_USE_SYSTEM_OPUSENC=ON"
61 "-DMUE_COMPILE_USE_SYSTEM_FLAC=ON"
62 # Don't bundle qt qml files, relevant really only for darwin, but we set
63 # this for all platforms anyway.
64 "-DMUE_COMPILE_INSTALL_QTQML_FILES=OFF"
65 # Don't build unit tests unless we are going to run them.
66 (lib.cmakeBool "MUSE_ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck)
71 # MuseScore JACK backend loads libjack at runtime.
72 "--prefix ${lib.optionalString stdenv.hostPlatform.isDarwin "DY"}LD_LIBRARY_PATH : ${
73 lib.makeLibraryPath [ libjack2 ]
76 ++ lib.optionals (stdenv.hostPlatform.isLinux) [
77 "--set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib"
79 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
80 # There are some issues with using the wayland backend, see:
81 # https://musescore.org/en/node/321936
82 "--set-default QT_QPA_PLATFORM xcb"
86 qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
99 ++ lib.optionals stdenv.hostPlatform.isLinux [
100 # Since https://github.com/musescore/MuseScore/pull/13847/commits/685ac998
101 # GTK3 is needed for file dialogs. Fixes crash with No GSettings schemas error.
127 ++ lib.optionals stdenv.hostPlatform.isLinux [
131 ++ lib.optionals stdenv.hostPlatform.isDarwin [
137 # Remove unneeded bundled libraries and headers
138 rm -r $out/{include,lib}
140 + lib.optionalString stdenv.hostPlatform.isDarwin ''
141 mkdir -p "$out/Applications"
142 mv "$out/mscore.app" "$out/Applications/mscore.app"
144 ln -s $out/Applications/mscore.app/Contents/MacOS/mscore $out/bin/mscore
147 # muse-sounds-manager installs Muse Sounds sampler libMuseSamplerCoreLib.so.
148 # It requires that argv0 of the calling process ends with "/mscore" or "/MuseScore-4".
149 # We need to ensure this in two cases:
151 # 1) when the user invokes MuseScore as "mscore" on the command line or from
152 # the .desktop file, and the normal argv0 is "mscore" (no "/");
153 # 2) when MuseScore invokes itself via File -> New, and the normal argv0 is
154 # the target of /proc/self/exe, which in Nixpkgs was "{...}/.mscore-wrapped"
156 # In order to achieve (2) we install the final binary as $out/libexec/mscore, and
157 # in order to achieve (1) we use makeWrapper without --inherit-argv0.
159 # wrapQtAppsHook uses wrapQtApp -> wrapProgram -> makeBinaryWrapper --inherit-argv0
160 # so we disable it and explicitly use makeQtWrapper.
162 # TODO: check if something like this is also needed for macOS.
163 dontWrapQtApps = stdenv.hostPlatform.isLinux;
164 postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
165 mkdir -p $out/libexec
166 mv $out/bin/mscore $out/libexec
167 makeQtWrapper $out/libexec/mscore $out/bin/mscore
170 # Don't run bundled upstreams tests, as they require a running X window system.
173 passthru.tests = nixosTests.musescore;
176 description = "Music notation and composition software";
177 homepage = "https://musescore.org/";
178 license = licenses.gpl3Only;
179 maintainers = with maintainers; [
184 mainProgram = "mscore";
185 platforms = platforms.unix;