Subject: Re: bug#57984: [PATCH] gnu: Update zynaddsubfx to 3.0.6

From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 13:37:28 +0000

Thank you Maxim and Maxime for your detailed review. I considered all of the changes you pointed out, and here are the attatchments of the new patch files. Regarding recursive clone, I packages the runtime dependencies seperately but I left the mruby gems, since they seem to be needed just as source (without needing to be compiled) as they are to be configured by mruby for mruby-zest. I am also not familier with mruby or ruby.

Thanks,

Sughosha

From 7e70f3c2eaae43367db6c4915cb43817cdee814c Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Wed, 21 Sep 2022 19:15:47 +0200
Subject: [PATCH 1/4] gnu: Add nanovg

* gnu/packages/music.scm (nanovg): New variable.
---
 gnu/packages/music.scm | 209 +++++++++++++++++++++++++++++++++++------
 1 file changed, 180 insertions(+), 29 deletions(-)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 6b37c79389..5d3c19bc78 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -167,6 +167,7 @@ (define-module (gnu packages music)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages rsync)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages sphinx)
@@ -2989,45 +2990,195 @@ (define-public vmpk
 instrument or MIDI file player.")
     (license license:gpl3+)))
 
+(define-public nanovg
+  (let ((commit "b83cf926525e7cea8d2483da2a75852b8c7b6d28")
+        (revision "268"))
+    (package
+      (name "nanovg")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/memononen/nanovg")
+                      (commit commit)))
+                (sha256
+                 (base32
+                  "1zp355pw6xnb5mjarz67cxkglv7j1s0qzv705fz1wf0gl0sjhy8f"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:tests? #f ;no test suite
+             #:phases #~(modify-phases %standard-phases
+                          (delete 'configure)
+                          (replace 'build
+                            (lambda _
+                              (invoke #$(cc-for-target) "src/nanovg.c" "-c"
+                                      "-fPIC")))
+                          (replace 'install
+                            (lambda _
+                              (let ((lib (string-append #$output "/lib")))
+                                (mkdir-p lib)
+                                (invoke "ar" "rc"
+                                        (string-append lib "/libnanovg.a")
+                                        "nanovg.o")))))))
+      (home-page "https://github.com/memononen/nanovg")
+      (synopsis "Antialiased 2D vector drawing library")
+      (description
+       "NanoVG is small antialiased vector graphics rendering library for
+OpenGL.  It has lean API modeled after HTML5 canvas API.")
+      (license license:zlib))))
+
+(define-public mruby-zest
+  (package
+    (name "mruby-zest")
+    (version "3.0.6")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/mruby-zest/mruby-zest-build")
+                    (commit version)
+                    ;; TODO: package mruby gems seperately.
+                    (recursive? #t)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0dz4zv1km9805lji2q2qqdd8s8hgfd723dxdzcivbhm612szm1mc"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:tests? #f ;no test suite
+           #:make-flags #~(list (string-append "CC="
+                                               #$(cc-for-target))
+                                "CONFIG_SHELL=bash")
+           #:phases #~(modify-phases %standard-phases
+                        (delete 'configure) ;no configure script
+                        (add-after 'unpack 'use-installed-libs
+                          (lambda _
+                            (substitute* "Makefile"
+                              (("cd deps/nanovg")
+                               "#cd deps/nanovg")
+                              (("\\$\\(AR\\) rc deps/libnanovg\\.a")
+                               "#\\$\\(AR\\) rc deps/libnanovg\\.a")
+                              (("cd deps/mruby-file-stat")
+                               "#cd deps/mruby-file-stat")
+                              (("\\./deps/libnanovg\\.a")
+                               "-lnanovg"))
+                            (substitute* "build_config.rb"
+                              (("#\\{`pwd`\\.strip\\}/\\.\\./deps/libnanovg\\.a")
+                               (string-append #$nanovg "/lib/libnanovg\\.a")))))
+                        (add-after 'unpack 'disable-unused-deps
+                          (lambda _
+                            (substitute* "build_config.rb"
+                              (("conf\\.gem 'deps/mruby-file-stat'")
+                               "#"))
+                            (substitute* "deps/mruby-dir-glob/mrbgem.rake"
+                              (("spec\\.add_dependency 'mruby-file-stat'")
+                               "#"))))
+                        (replace 'install
+                          (lambda _
+                            (let* ((lib (string-append #$output
+                                                       "/lib/zyn-fusion"))
+                                   (font (string-append lib "/font"))
+                                   (qml (string-append lib "/qml"))
+                                   (roboto (string-append #$font-google-roboto
+                                            "/share/fonts/truetype"))
+                                   (bin (string-append #$output "/bin")))
+                              ;; Hardcoded to use these font in this path.
+                              (mkdir-p (string-append lib "/font"))
+                              (symlink (string-append #$font-entypo
+                                                      "/share/fonts/truetype"
+                                                      "/entypo.ttf")
+                                       (string-append font "/entypo.ttf"))
+                              (symlink (string-append roboto
+                                                      "/Roboto-Bold.ttf")
+                                       (string-append font "/Roboto-Bold.ttf"))
+                              (symlink (string-append roboto
+                                                      "/Roboto-Light.ttf")
+                                       (string-append font "/Roboto-Light.ttf"))
+                              (symlink (string-append roboto
+                                                      "/Roboto-Regular.ttf")
+                                       (string-append font
+                                                      "/Roboto-Regular.ttf"))
+                              (copy-recursively "src/mruby-zest/qml" qml)
+                              (copy-recursively "src/mruby-zest/example" qml)
+                              (install-file "src/osc-bridge/schema/test.json"
+                                            (string-append lib "/schema"))
+                              (install-file "libzest.so" lib)
+                              ;; zynaddsubfx requires this name.
+                              (rename-file "zest" "zyn-fusion")
+                              (install-file "zyn-fusion" bin)
+                              (install-file "completions/zyn-fusion"
+                                            (string-append #$output
+                                             "/share/bash-completion/completions")))))
+                        (add-after 'install 'wrap
+                          (lambda _
+                            (wrap-program (string-append #$output
+                                                         "/bin/zyn-fusion")
+                             `("LD_LIBRARY_PATH" ":" prefix
+                                (,(string-append #$output
+                                                 "/lib/zyn-fusion")))))))))
+    (native-inputs (list mruby pkg-config ruby))
+    (inputs (list font-entypo
+                  font-google-roboto
+                  bash-minimal
+                  libuv
+                  libx11
+                  mesa
+                  nanovg))
+    (home-page "https://github.com/mruby-zest/mruby-zest-build")
+    (synopsis "Widget classes for the mruby-zest framework")
+    (description
+     "This repository contains all of the widgets needed to create the
+@code{zyn-fusion} user interface for ZynAddSubFX.")
+    (license license:lgpl2.1)))
+
 (define-public zynaddsubfx
   (package
     (name "zynaddsubfx")
-    (version "3.0.5")
+    (version (package-version mruby-zest))
     (source (origin
               (method url-fetch)
               (uri (string-append
-                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/"
-                    version "/zynaddsubfx-" version ".tar.bz2"))
+                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/" version
+                    "/zynaddsubfx-" version ".tar.bz2"))
               (sha256
                (base32
-                "0qwzg14h043rmyf9jqdylxhyfy4sl0vsr0gjql51wjhid0i34ivl"))))
+                "1bkirvcg0lz1i7ypnz3dyh218yhrqpnijxs8n3wlgwbcixvn1lfb"))))
     (build-system cmake-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         ;; Move SSE compiler optimization flags from generic target to
-         ;; athlon64 and core2 targets, because otherwise the build would fail
-         ;; on non-Intel machines.
-         (add-after 'unpack 'remove-sse-flags-from-generic-target
-          (lambda _
-            (substitute* "src/CMakeLists.txt"
-              (("-msse -msse2 -mfpmath=sse") "")
-              (("-march=(athlon64|core2)" flag)
-               (string-append flag " -msse -msse2 -mfpmath=sse")))
-            #t)))))
-    (inputs
-     (list liblo
-           ntk
-           mesa
-           alsa-lib
-           jack-1
-           fftw
-           minixml
-           libxpm
-           zlib))
-    (native-inputs
-     (list pkg-config))
-    (home-page "http://zynaddsubfx.sf.net/")
+     (list #:configure-flags #~(list "-DGuiModule=zest"
+                                     (string-append "-DZYN_DATADIR="
+                                                    #$output
+                                                    "/share/zynaddsubfx"))
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'remove-sse-flags-from-generic-target
+                          (lambda _
+                            (substitute* "src/CMakeLists.txt"
+                              (("-msse -msse2 -mfpmath=sse")
+                               "")
+                              (("-march=(athlon64|core2)" flag)
+                               (string-append flag
+                                              " -msse -msse2 -mfpmath=sse")))))
+                        (add-after 'unpack 'fix-zyn-fusion-path
+                          (lambda _
+                            (substitute* "src/main.cpp"
+                              (("\\./zyn-fusion")
+                               (string-append #$mruby-zest
+                                              "/bin/zyn-fusion")))
+                            (substitute*
+                             "src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp"
+                              (("\\./libzest\\.so")
+                               (string-append #$mruby-zest
+                                              "/lib/zyn-fusion/libzest.so"))))))))
+    (inputs (list alsa-lib
+                  fftwf
+                  jack-1
+                  liblo
+                  libxpm
+                  mesa
+                  minixml
+                  mruby-zest
+                  zlib))
+    (native-inputs (list doxygen pkg-config ruby))
+    (home-page "https://zynaddsubfx.sourceforge.io/")
     (synopsis "Software synthesizer")
     (description
      "ZynAddSubFX is a feature heavy realtime software synthesizer.  It offers
-- 
2.38.0

From f0f95c3a9478c38eb7cba1b9ffb0a9e9396e8034 Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:03:57 +0200
Subject: [PATCH 2/4] gnu: Add font-entypo

* gnu/packages/fonts.scm (font-entypo): New variable.
---
 gnu/packages/fonts.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 2d653abf32..639d2fa2b9 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -2882,3 +2882,27 @@ (define-public font-chiron-hei-hk
 Kong variant of Adobe’s Source Han Sans.  The font aims at providing a modern,
 region-agnostic glyph set adopting the “modern” glyph style that is similar to
 prevalent typefaces in Traditional Chinese regions.")))
+
+(define-public font-entypo
+  (let ((commit "f94e077449daa87321aa0df5643889460ba8291b")
+        (revision "117"))
+    (package
+      (name "font-entypo")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/danielbruce/entypo")
+               (commit commit)))
+         (sha256
+          (base32
+           "0kgy2ia15q93ksh6kbj8p5n44mmmax95w6a5byimbvcqajmvv7m6"))))
+      (build-system font-build-system)
+      (home-page "https://entypo.com")
+      (synopsis "Entypo font")
+      (description
+       "Entypo font is a pictogram suite.")
+      ;; Icons are distributed under CC-BY-SA 3.0 and fonts are distributed
+      ;; under SIL OFL.
+      (license (list license:cc-by-sa3.0 license:silofl1.1)))))
-- 
2.38.0

From 1493a9215bfe32b848d3ec44edcb9c6245d60714 Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:06:23 +0200
Subject: [PATCH 3/4] gnu: Add mruby-zest

* gnu/packages/fonts.scm (mruby-zest): New variable.
---
 gnu/packages/music.scm | 68 ++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 5d3c19bc78..a09eb6528d 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -3133,52 +3133,42 @@ (define-public mruby-zest
 (define-public zynaddsubfx
   (package
     (name "zynaddsubfx")
-    (version (package-version mruby-zest))
+    (version "3.0.5")
     (source (origin
               (method url-fetch)
               (uri (string-append
-                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/" version
-                    "/zynaddsubfx-" version ".tar.bz2"))
+                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/"
+                    version "/zynaddsubfx-" version ".tar.bz2"))
               (sha256
                (base32
-                "1bkirvcg0lz1i7ypnz3dyh218yhrqpnijxs8n3wlgwbcixvn1lfb"))))
+                "0qwzg14h043rmyf9jqdylxhyfy4sl0vsr0gjql51wjhid0i34ivl"))))
     (build-system cmake-build-system)
     (arguments
-     (list #:configure-flags #~(list "-DGuiModule=zest"
-                                     (string-append "-DZYN_DATADIR="
-                                                    #$output
-                                                    "/share/zynaddsubfx"))
-           #:phases #~(modify-phases %standard-phases
-                        (add-after 'unpack 'remove-sse-flags-from-generic-target
-                          (lambda _
-                            (substitute* "src/CMakeLists.txt"
-                              (("-msse -msse2 -mfpmath=sse")
-                               "")
-                              (("-march=(athlon64|core2)" flag)
-                               (string-append flag
-                                              " -msse -msse2 -mfpmath=sse")))))
-                        (add-after 'unpack 'fix-zyn-fusion-path
-                          (lambda _
-                            (substitute* "src/main.cpp"
-                              (("\\./zyn-fusion")
-                               (string-append #$mruby-zest
-                                              "/bin/zyn-fusion")))
-                            (substitute*
-                             "src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp"
-                              (("\\./libzest\\.so")
-                               (string-append #$mruby-zest
-                                              "/lib/zyn-fusion/libzest.so"))))))))
-    (inputs (list alsa-lib
-                  fftwf
-                  jack-1
-                  liblo
-                  libxpm
-                  mesa
-                  minixml
-                  mruby-zest
-                  zlib))
-    (native-inputs (list doxygen pkg-config ruby))
-    (home-page "https://zynaddsubfx.sourceforge.io/")
+     `(#:phases
+       (modify-phases %standard-phases
+         ;; Move SSE compiler optimization flags from generic target to
+         ;; athlon64 and core2 targets, because otherwise the build would fail
+         ;; on non-Intel machines.
+         (add-after 'unpack 'remove-sse-flags-from-generic-target
+          (lambda _
+            (substitute* "src/CMakeLists.txt"
+              (("-msse -msse2 -mfpmath=sse") "")
+              (("-march=(athlon64|core2)" flag)
+               (string-append flag " -msse -msse2 -mfpmath=sse")))
+            #t)))))
+    (inputs
+     (list liblo
+           ntk
+           mesa
+           alsa-lib
+           jack-1
+           fftw
+           minixml
+           libxpm
+           zlib))
+    (native-inputs
+     (list pkg-config))
+    (home-page "http://zynaddsubfx.sf.net/")
     (synopsis "Software synthesizer")
     (description
      "ZynAddSubFX is a feature heavy realtime software synthesizer.  It offers
-- 
2.38.0

From 17adfad1899b58edb51e5c6fd56b5200ca8f4cdc Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:16:30 +0200
Subject: [PATCH 4/4] gnu: zynaddsubfx: Update to 3.0.6 and switch to
 zyn-fusion

* gnu/packages/music.scm (zynaddsubfx): Update to 3.0.6.

[arguments]: Switch from NTK to Zest and use gexp.

[inputs]: Replace ntk with mruby-zest.

[native-inputs]: New dependencies.
---
 gnu/packages/music.scm | 68 ++++++++++++++++++++++++------------------
 1 file changed, 39 insertions(+), 29 deletions(-)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index a09eb6528d..5d3c19bc78 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -3133,42 +3133,52 @@ (define-public mruby-zest
 (define-public zynaddsubfx
   (package
     (name "zynaddsubfx")
-    (version "3.0.5")
+    (version (package-version mruby-zest))
     (source (origin
               (method url-fetch)
               (uri (string-append
-                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/"
-                    version "/zynaddsubfx-" version ".tar.bz2"))
+                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/" version
+                    "/zynaddsubfx-" version ".tar.bz2"))
               (sha256
                (base32
-                "0qwzg14h043rmyf9jqdylxhyfy4sl0vsr0gjql51wjhid0i34ivl"))))
+                "1bkirvcg0lz1i7ypnz3dyh218yhrqpnijxs8n3wlgwbcixvn1lfb"))))
     (build-system cmake-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         ;; Move SSE compiler optimization flags from generic target to
-         ;; athlon64 and core2 targets, because otherwise the build would fail
-         ;; on non-Intel machines.
-         (add-after 'unpack 'remove-sse-flags-from-generic-target
-          (lambda _
-            (substitute* "src/CMakeLists.txt"
-              (("-msse -msse2 -mfpmath=sse") "")
-              (("-march=(athlon64|core2)" flag)
-               (string-append flag " -msse -msse2 -mfpmath=sse")))
-            #t)))))
-    (inputs
-     (list liblo
-           ntk
-           mesa
-           alsa-lib
-           jack-1
-           fftw
-           minixml
-           libxpm
-           zlib))
-    (native-inputs
-     (list pkg-config))
-    (home-page "http://zynaddsubfx.sf.net/")
+     (list #:configure-flags #~(list "-DGuiModule=zest"
+                                     (string-append "-DZYN_DATADIR="
+                                                    #$output
+                                                    "/share/zynaddsubfx"))
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'remove-sse-flags-from-generic-target
+                          (lambda _
+                            (substitute* "src/CMakeLists.txt"
+                              (("-msse -msse2 -mfpmath=sse")
+                               "")
+                              (("-march=(athlon64|core2)" flag)
+                               (string-append flag
+                                              " -msse -msse2 -mfpmath=sse")))))
+                        (add-after 'unpack 'fix-zyn-fusion-path
+                          (lambda _
+                            (substitute* "src/main.cpp"
+                              (("\\./zyn-fusion")
+                               (string-append #$mruby-zest
+                                              "/bin/zyn-fusion")))
+                            (substitute*
+                             "src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp"
+                              (("\\./libzest\\.so")
+                               (string-append #$mruby-zest
+                                              "/lib/zyn-fusion/libzest.so"))))))))
+    (inputs (list alsa-lib
+                  fftwf
+                  jack-1
+                  liblo
+                  libxpm
+                  mesa
+                  minixml
+                  mruby-zest
+                  zlib))
+    (native-inputs (list doxygen pkg-config ruby))
+    (home-page "https://zynaddsubfx.sourceforge.io/")
     (synopsis "Software synthesizer")
     (description
      "ZynAddSubFX is a feature heavy realtime software synthesizer.  It offers
-- 
2.38.0