From 857317452af2e10f05b6c7e906ddca13d4c915ff Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 3 Nov 2024 15:05:08 +0200 Subject: [PATCH 1/5] musescore: 4.4.1 -> 4.4.3 --- pkgs/applications/audio/musescore/default.nix | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index fbfc50a1a684..7c5328a15a08 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -1,7 +1,6 @@ { stdenv , lib , fetchFromGitHub -, fetchpatch , cmake , wrapQtAppsHook , pkg-config @@ -49,22 +48,14 @@ let } else portaudio; in stdenv'.mkDerivation (finalAttrs: { pname = "musescore"; - version = "4.4.1"; + version = "4.4.3"; src = fetchFromGitHub { owner = "musescore"; repo = "MuseScore"; rev = "v${finalAttrs.version}"; - sha256 = "sha256-eLtpLgXSc8L5y1Mg3s1wrxr09+/vBxNqJEtl9IoKYSM="; + sha256 = "sha256-bHpPhav9JBPkwJA9o+IFHRWbvxWnGkD1wHBHS4XJ/YE="; }; - patches = [ - # https://github.com/musescore/MuseScore/pull/24326 - (fetchpatch { - name = "fix-menubar-with-qt6.5+.patch"; - url = "https://github.com/musescore/MuseScore/pull/24326/commits/b274f13311ad0b2bce339634a006ba22fbd3379e.patch"; - hash = "sha256-ZGmjRa01CBEIxJdJYQMhdg4A9yjWdlgn0pCPmENBTq0="; - }) - ]; cmakeFlags = [ "-DMUSE_APP_BUILD_MODE=release" @@ -82,6 +73,8 @@ in stdenv'.mkDerivation (finalAttrs: { # Don't bundle qt qml files, relevant really only for darwin, but we set # this for all platforms anyway. "-DMUE_COMPILE_INSTALL_QTQML_FILES=OFF" + # Don't build unit tests unless we are going to run them. + (lib.cmakeBool "MUSE_ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck) ]; qtWrapperArgs = [ From e587e0db6b179d55cc5c884463632e06b4a6ac8d Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 3 Nov 2024 15:07:37 +0200 Subject: [PATCH 2/5] musescore: fix GTK3 wrapping, for file dialogs --- pkgs/applications/audio/musescore/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index 7c5328a15a08..eb661c1f7074 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -2,6 +2,7 @@ , lib , fetchFromGitHub , cmake +, wrapGAppsHook3 , wrapQtAppsHook , pkg-config , ninja @@ -88,12 +89,22 @@ in stdenv'.mkDerivation (finalAttrs: { "--set-default QT_QPA_PLATFORM xcb" ]; + preFixup = '' + qtWrapperArgs+=("''${gappsWrapperArgs[@]}") + ''; + + dontWrapGApps = true; + nativeBuildInputs = [ wrapQtAppsHook cmake qttools pkg-config ninja + ] ++ lib.optionals stdenv.hostPlatform.isLinux [ + # Since https://github.com/musescore/MuseScore/pull/13847/commits/685ac998 + # GTK3 is needed for file dialogs. Fixes crash with No GSettings schemas error. + wrapGAppsHook3 ]; buildInputs = [ From 159de791a3b5bca2d42a75a77522398f1c4c5b9f Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 3 Nov 2024 15:08:47 +0200 Subject: [PATCH 3/5] musescore: Fix muse-sounds-manager issue --- pkgs/applications/audio/musescore/default.nix | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index eb661c1f7074..09baad05f9ce 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -144,6 +144,29 @@ in stdenv'.mkDerivation (finalAttrs: { ln -s $out/Applications/mscore.app/Contents/MacOS/mscore $out/bin/mscore ''; + # muse-sounds-manager installs Muse Sounds sampler libMuseSamplerCoreLib.so. + # It requires that argv0 of the calling process ends with "/mscore" or "/MuseScore-4". + # We need to ensure this in two cases: + # + # 1) when the user invokes MuseScore as "mscore" on the command line or from + # the .desktop file, and the normal argv0 is "mscore" (no "/"); + # 2) when MuseScore invokes itself via File -> New, and the normal argv0 is + # the target of /proc/self/exe, which in Nixpkgs was "{...}/.mscore-wrapped" + # + # In order to achieve (2) we install the final binary as $out/libexec/mscore, and + # in order to achieve (1) we use makeWrapper without --inherit-argv0. + # + # wrapQtAppsHook uses wrapQtApp -> wrapProgram -> makeBinaryWrapper --inherit-argv0 + # so we disable it and explicitly use makeQtWrapper. + # + # TODO: check if something like this is also needed for macOS. + dontWrapQtApps = stdenv.isLinux; + postFixup = lib.optionalString stdenv.isLinux '' + mkdir -p $out/libexec + mv $out/bin/mscore $out/libexec + makeQtWrapper $out/libexec/mscore $out/bin/mscore + ''; + # Don't run bundled upstreams tests, as they require a running X window system. doCheck = false; From c3ebcfc84e84b00e439f389ab97a65dbf0d94df6 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 3 Nov 2024 15:09:48 +0200 Subject: [PATCH 4/5] musescore: explicitly use stdenv.hostPlatform --- pkgs/applications/audio/musescore/default.nix | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index 09baad05f9ce..379a878bd102 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -34,10 +34,10 @@ }: let - stdenv' = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv; + stdenv' = if stdenv.hostPlatform.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv; # portaudio propagates Darwin frameworks. Rebuild it using the 11.0 stdenv # from Qt and the 11.0 SDK frameworks. - portaudio' = if stdenv.isDarwin then portaudio.override { + portaudio' = if stdenv.hostPlatform.isDarwin then portaudio.override { stdenv = stdenv'; inherit (darwin.apple_sdk_11_0.frameworks) AudioUnit @@ -80,10 +80,10 @@ in stdenv'.mkDerivation (finalAttrs: { qtWrapperArgs = [ # MuseScore JACK backend loads libjack at runtime. - "--prefix ${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libjack2 ]}" - ] ++ lib.optionals (stdenv.isLinux) [ + "--prefix ${lib.optionalString stdenv.hostPlatform.isDarwin "DY"}LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libjack2 ]}" + ] ++ lib.optionals (stdenv.hostPlatform.isLinux) [ "--set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib" - ] ++ lib.optionals (!stdenv.isDarwin) [ + ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ # There are some issues with using the wayland backend, see: # https://musescore.org/en/node/321936 "--set-default QT_QPA_PLATFORM xcb" @@ -127,17 +127,17 @@ in stdenv'.mkDerivation (finalAttrs: { qtsvg qtscxml qtnetworkauth - ] ++ lib.optionals stdenv.isLinux [ + ] ++ lib.optionals stdenv.hostPlatform.isLinux [ alsa-lib qtwayland - ] ++ lib.optionals stdenv.isDarwin [ + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk_11_0.frameworks.Cocoa ]; postInstall = '' # Remove unneeded bundled libraries and headers rm -r $out/{include,lib} - '' + lib.optionalString stdenv.isDarwin '' + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' mkdir -p "$out/Applications" mv "$out/mscore.app" "$out/Applications/mscore.app" mkdir -p $out/bin @@ -160,8 +160,8 @@ in stdenv'.mkDerivation (finalAttrs: { # so we disable it and explicitly use makeQtWrapper. # # TODO: check if something like this is also needed for macOS. - dontWrapQtApps = stdenv.isLinux; - postFixup = lib.optionalString stdenv.isLinux '' + dontWrapQtApps = stdenv.hostPlatform.isLinux; + postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' mkdir -p $out/libexec mv $out/bin/mscore $out/libexec makeQtWrapper $out/libexec/mscore $out/bin/mscore From 44cd53a4de1b8c504414b93a481ad76bd6b8aea1 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 3 Jun 2024 02:28:26 +0300 Subject: [PATCH 5/5] nixos.tests.musescore: fix and improve - Use the print dialog to create a sample score. - Copy also the sample score from the vm to $out of the test. - Create a bit more screenshots - Only use machine.wait_for_window, never machine.wait_for_text which requires OCR which is slow. - Set XDG_RUNTIME_DIR so it won't dump core. --- nixos/tests/musescore.nix | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/nixos/tests/musescore.nix b/nixos/tests/musescore.nix index 0720631ed284..559c91ed8e55 100644 --- a/nixos/tests/musescore.nix +++ b/nixos/tests/musescore.nix @@ -43,13 +43,10 @@ in ) # Start MuseScore window - machine.execute("DISPLAY=:0.0 mscore >&2 &") + machine.execute("env XDG_RUNTIME_DIR=$PWD DISPLAY=:0.0 mscore >&2 &") # Wait until MuseScore has launched - machine.wait_for_window("MuseScore 4") - - # Wait until the window has completely initialised - machine.wait_for_text("MuseScore 4") + machine.wait_for_window("MuseScore Studio") machine.screenshot("MuseScore0") @@ -75,29 +72,22 @@ in machine.screenshot("MuseScore2") # Go to the export dialogue and create a PDF - machine.send_key("alt-f") - machine.sleep(1) - machine.send_key("e") + machine.send_key("ctrl-p") - # Wait until the export dialogue appears. - machine.wait_for_text("Export") - - machine.screenshot("MuseScore3") - - machine.send_key("shift-tab") - machine.sleep(1) - machine.send_key("ret") - machine.sleep(1) - machine.send_key("ret") + # Wait until the Print dialogue appears. + machine.wait_for_window("Print") machine.screenshot("MuseScore4") - - # Wait until PDF is exported - machine.wait_for_file('"/root/Documents/MuseScore4/Scores/Untitled score.pdf"') - - # Check that it contains the title of the score - machine.succeed('pdfgrep "Untitled score" "/root/Documents/MuseScore4/Scores/Untitled score.pdf"') + machine.send_key("alt-p") + machine.sleep(1) machine.screenshot("MuseScore5") + + # Wait until PDF is exported + machine.wait_for_file('"/root/Untitled score.pdf"') + + ## Check that it contains the title of the score + machine.succeed('pdfgrep "Untitled score" "/root/Untitled score.pdf"') + machine.copy_from_vm("/root/Untitled score.pdf") ''; })