From 47919debed4d3d32538ce761ee02f9b40221f319 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 13 Jul 2023 18:03:20 +0300 Subject: [PATCH 1/6] musescore: 4.0.2 -> 4.1.0 Diff: https://github.com/musescore/MuseScore/compare/v4.0.2...v4.1.0 --- pkgs/applications/audio/musescore/darwin.nix | 6 +++--- pkgs/applications/audio/musescore/default.nix | 20 +++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/pkgs/applications/audio/musescore/darwin.nix b/pkgs/applications/audio/musescore/darwin.nix index 652adb03b66a..257a4e16405f 100644 --- a/pkgs/applications/audio/musescore/darwin.nix +++ b/pkgs/applications/audio/musescore/darwin.nix @@ -1,9 +1,9 @@ { stdenv, lib, fetchurl, undmg }: let - versionComponents = [ "4" "0" "1" ]; + versionComponents = [ "4" "1" "0" ]; appName = "MuseScore ${builtins.head versionComponents}"; - ref = "230121751"; + ref = "231921401"; in stdenv.mkDerivation rec { @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { src = fetchurl { url = "https://github.com/musescore/MuseScore/releases/download/v${version}/MuseScore-${version}.${ref}.dmg"; - hash = "sha256-tkIEV+tCS0SYh2TlC70/zEBUEOSg//EaSKDGA7kH/vo="; + hash = "sha256-uyhGWcKSELz7WiWxZPoEJ+L5VvnHZFaU6aQtwhmmhHk="; }; buildInputs = [ undmg ]; diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index 15828d25729c..f518307d93ea 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -8,27 +8,21 @@ mkDerivation rec { pname = "musescore"; - version = "4.0.2"; + version = "4.1.0"; src = fetchFromGitHub { owner = "musescore"; repo = "MuseScore"; rev = "v${version}"; - sha256 = "sha256-3NSHUdTyAC/WOhkB6yBrqtV3LV4Hl1m3poB3ojtJMfs="; + sha256 = "sha256-CqW1f0VsF2lW79L3FY2ev+6FoHLbYOJ9LWHeBlWegeU="; }; - patches = [ - # See https://github.com/musescore/MuseScore/issues/15571 - (fetchpatch { - url = "https://github.com/musescore/MuseScore/commit/365be5dfb7296ebee4677cb74b67c1721bc2cf7b.patch"; - hash = "sha256-tJ2M21i3geO9OsjUQKNatSXTkJ5U9qMT4RLNdJnyoKw="; - }) - ]; cmakeFlags = [ - "-DMUSESCORE_BUILD_CONFIG=release" - # Disable the _usage_ of the `/bin/crashpad_handler` utility. See: - # https://github.com/musescore/MuseScore/pull/15577 - "-DBUILD_CRASHPAD_CLIENT=OFF" + "-DMUSESCORE_BUILD_MODE=release" + # Disable the build and usage of the `/bin/crashpad_handler` utility - it's + # not useful on NixOS, see: + # https://github.com/musescore/MuseScore/issues/15571 + "-DMUE_BUILD_CRASHPAD_CLIENT=OFF" # Use our freetype "-DUSE_SYSTEM_FREETYPE=ON" ]; From 85b756369f28952994979a45d307fb7400310896 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 14 Jul 2023 15:05:46 +0300 Subject: [PATCH 2/6] musescore: format with nixpkgs-fmt --- pkgs/applications/audio/musescore/default.nix | 66 ++++++++++++++++--- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index f518307d93ea..ebe9430cf62b 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -1,8 +1,32 @@ -{ mkDerivation, lib, fetchFromGitHub, fetchpatch, cmake, pkg-config, ninja -, alsa-lib, freetype, libjack2, lame, libogg, libpulseaudio, libsndfile, libvorbis -, portaudio, portmidi, qtbase, qtdeclarative, qtgraphicaleffects, flac -, qtquickcontrols2, qtscript, qtsvg, qttools -, qtwebengine, qtxmlpatterns, qtnetworkauth, qtx11extras +{ mkDerivation +, lib +, fetchFromGitHub +, fetchpatch +, cmake +, pkg-config +, ninja +, alsa-lib +, freetype +, libjack2 +, lame +, libogg +, libpulseaudio +, libsndfile +, libvorbis +, portaudio +, portmidi +, qtbase +, qtdeclarative +, qtgraphicaleffects +, flac +, qtquickcontrols2 +, qtscript +, qtsvg +, qttools +, qtwebengine +, qtxmlpatterns +, qtnetworkauth +, qtx11extras , nixosTests }: @@ -35,13 +59,35 @@ mkDerivation rec { "--set-default QT_QPA_PLATFORM xcb" ]; - nativeBuildInputs = [ cmake pkg-config ninja ]; + nativeBuildInputs = [ + cmake + pkg-config + ninja + ]; buildInputs = [ - alsa-lib libjack2 freetype lame libogg libpulseaudio libsndfile libvorbis - portaudio portmidi flac # tesseract - qtbase qtdeclarative qtgraphicaleffects qtquickcontrols2 - qtscript qtsvg qttools qtwebengine qtxmlpatterns qtnetworkauth qtx11extras + alsa-lib + libjack2 + freetype + lame + libogg + libpulseaudio + libsndfile + libvorbis + portaudio + portmidi + flac + qtbase + qtdeclarative + qtgraphicaleffects + qtquickcontrols2 + qtscript + qtsvg + qttools + qtwebengine + qtxmlpatterns + qtnetworkauth + qtx11extras ]; passthru.tests = nixosTests.musescore; From 4416f5b78a27371de63d06aa0cc73cbbf9f0e8ea Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 14 Jul 2023 15:08:05 +0300 Subject: [PATCH 3/6] musescore: Switch to wrapQtAppsHook and stdenv.mkDerivation The usage of libsForQt5's mkDerivation is deprecated. --- pkgs/applications/audio/musescore/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index ebe9430cf62b..01be6ec7615a 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -1,8 +1,9 @@ -{ mkDerivation +{ stdenv , lib , fetchFromGitHub , fetchpatch , cmake +, wrapQtAppsHook , pkg-config , ninja , alsa-lib @@ -30,7 +31,7 @@ , nixosTests }: -mkDerivation rec { +stdenv.mkDerivation rec { pname = "musescore"; version = "4.1.0"; @@ -60,6 +61,7 @@ mkDerivation rec { ]; nativeBuildInputs = [ + wrapQtAppsHook cmake pkg-config ninja From 3b32c6f516dd806348e2b2a4d0a5e9d078d7c9ce Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sat, 15 Jul 2023 16:26:09 +0300 Subject: [PATCH 4/6] musescore: Remove unneeded qt deps from buildInputs --- pkgs/applications/audio/musescore/default.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index 01be6ec7615a..1f3787712e3b 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -23,8 +23,6 @@ , qtquickcontrols2 , qtscript , qtsvg -, qttools -, qtwebengine , qtxmlpatterns , qtnetworkauth , qtx11extras @@ -85,8 +83,6 @@ stdenv.mkDerivation rec { qtquickcontrols2 qtscript qtsvg - qttools - qtwebengine qtxmlpatterns qtnetworkauth qtx11extras From 014929ac5041c6da91c78f5c1458b3ebad9078b6 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 17 Jul 2023 15:16:54 +0300 Subject: [PATCH 5/6] musescore: remove unneeded bundled libraries and headers from $out --- pkgs/applications/audio/musescore/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index 1f3787712e3b..2ea999cbc290 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -88,6 +88,11 @@ stdenv.mkDerivation rec { qtx11extras ]; + postInstall = '' + # Remove unneeded bundled libraries and headers + rm -r $out/{include,lib} + ''; + passthru.tests = nixosTests.musescore; meta = with lib; { From 8895d55614546816673685b08af17c1f4ad5676e Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sat, 15 Jul 2023 19:05:17 +0300 Subject: [PATCH 6/6] musescore: Fix darwin build from source Co-authored-by: Randy Eckenrode --- pkgs/applications/audio/musescore/darwin.nix | 35 ----------- pkgs/applications/audio/musescore/default.nix | 59 ++++++++++++++++--- pkgs/top-level/all-packages.nix | 7 +-- 3 files changed, 53 insertions(+), 48 deletions(-) delete mode 100644 pkgs/applications/audio/musescore/darwin.nix diff --git a/pkgs/applications/audio/musescore/darwin.nix b/pkgs/applications/audio/musescore/darwin.nix deleted file mode 100644 index 257a4e16405f..000000000000 --- a/pkgs/applications/audio/musescore/darwin.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ stdenv, lib, fetchurl, undmg }: - -let - versionComponents = [ "4" "1" "0" ]; - appName = "MuseScore ${builtins.head versionComponents}"; - ref = "231921401"; -in - -stdenv.mkDerivation rec { - pname = "musescore-darwin"; - version = lib.concatStringsSep "." versionComponents; - - # The disk image contains the .app and a symlink to /Applications. - sourceRoot = "${appName}.app"; - - src = fetchurl { - url = "https://github.com/musescore/MuseScore/releases/download/v${version}/MuseScore-${version}.${ref}.dmg"; - hash = "sha256-uyhGWcKSELz7WiWxZPoEJ+L5VvnHZFaU6aQtwhmmhHk="; - }; - - buildInputs = [ undmg ]; - installPhase = '' - mkdir -p "$out/Applications/${appName}.app" - cp -R . "$out/Applications/${appName}.app" - chmod a+x "$out/Applications/${appName}.app/Contents/MacOS/mscore" - ''; - - meta = with lib; { - description = "Music notation and composition software"; - homepage = "https://musescore.org/"; - license = licenses.gpl3Only; - platforms = platforms.darwin; - maintainers = []; - }; -} diff --git a/pkgs/applications/audio/musescore/default.nix b/pkgs/applications/audio/musescore/default.nix index 2ea999cbc290..fa166051db61 100644 --- a/pkgs/applications/audio/musescore/default.nix +++ b/pkgs/applications/audio/musescore/default.nix @@ -20,6 +20,7 @@ , qtdeclarative , qtgraphicaleffects , flac +, qtquickcontrols , qtquickcontrols2 , qtscript , qtsvg @@ -27,9 +28,24 @@ , qtnetworkauth , qtx11extras , nixosTests +, darwin }: -stdenv.mkDerivation rec { +let + stdenv' = if stdenv.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 { + stdenv = stdenv'; + inherit (darwin.apple_sdk_11_0.frameworks) + AudioUnit + AudioToolbox + CoreAudio + CoreServices + Carbon + ; + } else portaudio; +in stdenv'.mkDerivation rec { pname = "musescore"; version = "4.1.0"; @@ -39,6 +55,15 @@ stdenv.mkDerivation rec { rev = "v${version}"; sha256 = "sha256-CqW1f0VsF2lW79L3FY2ev+6FoHLbYOJ9LWHeBlWegeU="; }; + patches = [ + # Upstream from some reason wants to install qml files from qtbase in + # installPhase, this patch removes this behavior. See: + # https://github.com/musescore/MuseScore/issues/18665 + (fetchpatch { + url = "https://github.com/doronbehar/MuseScore/commit/f48448a3ede46f5a7ef470940072fbfb6742487c.patch"; + hash = "sha256-UEc7auscnW0KMfWkLKQtm+UstuTNsuFeoNJYIidIlwM="; + }) + ]; cmakeFlags = [ "-DMUSESCORE_BUILD_MODE=release" @@ -48,16 +73,29 @@ stdenv.mkDerivation rec { "-DMUE_BUILD_CRASHPAD_CLIENT=OFF" # Use our freetype "-DUSE_SYSTEM_FREETYPE=ON" + # From some reason, in $src/build/cmake/SetupBuildEnvironment.cmake, + # upstream defaults to compiling to x86_64 only, unless this cmake flag is + # set + "-DMUE_COMPILE_BUILD_MACOS_APPLE_SILICON=ON" + # 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" ]; qtWrapperArgs = [ # MuseScore JACK backend loads libjack at runtime. - "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libjack2 ]}" + "--prefix ${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libjack2 ]}" + ] ++ lib.optionals (!stdenv.isDarwin) [ # There are some issues with using the wayland backend, see: # https://musescore.org/en/node/321936 "--set-default QT_QPA_PLATFORM xcb" ]; + # HACK `propagatedSandboxProfile` does not appear to actually propagate the + # sandbox profile from `qtbase`, see: + # https://github.com/NixOS/nixpkgs/issues/237458 + sandboxProfile = toString qtbase.__propagatedSandboxProfile or null; + nativeBuildInputs = [ wrapQtAppsHook cmake @@ -66,7 +104,6 @@ stdenv.mkDerivation rec { ]; buildInputs = [ - alsa-lib libjack2 freetype lame @@ -74,23 +111,31 @@ stdenv.mkDerivation rec { libpulseaudio libsndfile libvorbis - portaudio + portaudio' portmidi flac qtbase qtdeclarative qtgraphicaleffects + qtquickcontrols qtquickcontrols2 qtscript qtsvg qtxmlpatterns qtnetworkauth qtx11extras + ] ++ lib.optionals stdenv.isLinux [ + alsa-lib ]; postInstall = '' # Remove unneeded bundled libraries and headers rm -r $out/{include,lib} + '' + lib.optionalString stdenv.isDarwin '' + mkdir -p "$out/Applications" + mv "$out/mscore.app" "$out/Applications/mscore.app" + mkdir -p $out/bin + ln -s $out/Applications/mscore.app/Contents/MacOS/mscore $out/bin/mscore. ''; passthru.tests = nixosTests.musescore; @@ -100,9 +145,9 @@ stdenv.mkDerivation rec { homepage = "https://musescore.org/"; license = licenses.gpl3Only; maintainers = with maintainers; [ vandenoever turion doronbehar ]; - # Darwin requires CoreMIDI from SDK 11.3, we use the upstream built .dmg - # file in ./darwin.nix in the meantime. - platforms = platforms.linux; + # on aarch64-linux: + # error: cannot convert '' to 'float32x4_t' in assignment + broken = (stdenv.isLinux && stdenv.isAarch64); mainProgram = "mscore"; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f23ca4524ab5..4fe3ce6aff06 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33367,12 +33367,7 @@ with pkgs; autoreconfHook = buildPackages.autoreconfHook269; }; - # TODO: we should probably merge these 2 - musescore = - if stdenv.isDarwin then - callPackage ../applications/audio/musescore/darwin.nix { } - else - libsForQt5.callPackage ../applications/audio/musescore { }; + musescore = libsForQt5.callPackage ../applications/audio/musescore { }; music-player = callPackage ../applications/audio/music-player { };