Subject: [PATCH] Add SuperCollider, related changes
From: Maxim Cournoyer <[email-masked]>
To: guix-patches <[email-masked]>
Date: Sun, 18 Mar 2018 22:30:28 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello!

After some cooperation with upstream to unbundle dependencies and
enable more tests, I think this SuperCollider package is in good shape!

Here's a screenshot to give you an idea of what the included IDE looks
like: 

Having a jackd service is not necessary (SuperCollider will start one if
it's not already running), but in case you'd like to have one I've found
the following to work with Shepherd:

--8<---------------cut here---------------start------------->8---
(define jackd
  (make <service>
    #:provides '(jackd)
    #:requires '()
    #:start (make-system-constructor "jackd -d alsa &")
    #:stop (make-system-destructor "pkill jackd")))
--8<---------------cut here---------------end--------------->8---

Thanks,

Maxim

From 59da2743aa90c9fb6f4099303f6481c636fc560e Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sat, 10 Mar 2018 23:09:56 -0500
Subject: [PATCH] doc: Add index entries for realtime and jackd in the manual.

* doc/guix.texi (Base Services): Add realtime and jackd indices to the
`pam-limits-service' service, as the examples shows how they can be
configured.
---
 doc/guix.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 13187f2e8..ff6a24d07 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10309,6 +10309,8 @@ to add @var{device} to the kernel's entropy pool.  The service will fail if
 @cindex session limits
 @cindex ulimit
 @cindex priority
+@cindex realtime
+@cindex jackd
 @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
 
 Return a service that installs a configuration file for the
-- 
2.16.1

From 8f7d8aeeb455038b223a429d3273a4b42299a85d Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 4 Mar 2018 22:50:04 -0500
Subject: [PATCH 1/3] gnu: Add boost-sync.

* gnu/packages/boost.scm (boost-sync): New variable.
---
 gnu/packages/boost.scm | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/gnu/packages/boost.scm b/gnu/packages/boost.scm
index f4ba82810..d347674ab 100644
--- a/gnu/packages/boost.scm
+++ b/gnu/packages/boost.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2015 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2017 Thomas Danckaert <[email-masked]>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <[email-masked]>
+;;; Copyright © 2018 Maxim Cournoyer <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,7 +27,10 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages icu4c)
@@ -124,6 +128,38 @@ across a broad spectrum of applications.")
                (base32
                 "1aaw48cmimsskzgiclwn0iifp62a5iw9cbqrhfari876af1828ap"))))))
 
+(define-public boost-sync
+  (let ((commit "c72891d9b90e2ceb466ec859f640cd012b2d8709")
+        (version "1.55")
+        (revision "1"))
+    (package
+      (name "boost-sync")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/boostorg/sync.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "197mp5z048vz5kv1m4v3jm447l2gqsyv0rbfz11dz0ns343ihbyx"))))
+      (build-system trivial-build-system)
+      (arguments
+       `(#:modules ((guix build utils))
+         #:builder
+         (begin
+           (use-modules (guix build utils))
+           (let ((source (assoc-ref %build-inputs "source")))
+             (copy-recursively (string-append source "/include")
+                               (string-append %output "/include"))))))
+      (home-page "https://github.com/boostorg/sync")
+      (synopsis "Boost.Sync library")
+      (description "The Boost.Sync library provides mutexes, semaphores, locks
+and events and other thread related facilities.  Boost.Sync originated from
+Boost.Thread.")
+      (license (license:x11-style "http://www.boost.org/LICENSE_1_0.txt")))))
+
 (define-public mdds
   (package
     (name "mdds")
-- 
2.16.1

From 44dc28c15144f8b3e7bc184a3271b34ba8132a40 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Mon, 5 Mar 2018 20:15:35 -0500
Subject: [PATCH 2/3] gnu: yaml-cpp: Update to 0.6.1.

* gnu/packages/serialization.scm (yaml-cpp): Update to 0.6.1.
---
 gnu/packages/serialization.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/serialization.scm b/gnu/packages/serialization.scm
index f72116575..7d2e88eac 100644
--- a/gnu/packages/serialization.scm
+++ b/gnu/packages/serialization.scm
@@ -248,7 +248,7 @@ that implements both the msgpack and msgpack-rpc specifications.")
 (define-public yaml-cpp
   (package
     (name "yaml-cpp")
-    (version "0.5.3")
+    (version "0.6.1")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -256,7 +256,7 @@ that implements both the msgpack and msgpack-rpc specifications.")
                     "yaml-cpp-" version ".tar.gz"))
               (sha256
                (base32
-                "1ck7jk0wjfigrf4cgcjqsir4yp1s6vamhhxhpsgfvs46pgm5pk6y"))))
+                "038ddf771d1zrdfiwqzq2lsjdis1fxbaasbdja2w9f1av3k3gv15"))))
     (build-system cmake-build-system)
     (arguments
      '(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")))
-- 
2.16.1

From 2ca1117e8d6709364362e4c5d39b2568ed8f9db5 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 4 Mar 2018 23:03:26 -0500
Subject: [PATCH 3/3] gnu: Add supercollider.

* gnu/packages/audio.scm (supercollider): New variable.
---
 gnu/packages/audio.scm | 111 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index d8569096a..79f399eb7 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2016, 2017, 2018 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2018 Oleg Pykhalov <[email-masked]>
 ;;; Copyright © 2018 okapi <[email-masked]>
+;;; Copyright © 2018 Maxim Cournoyer <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -62,6 +63,7 @@
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gnunet) ; libmicrohttpd
   #:use-module (gnu packages gperf)
+  #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages qt)
@@ -75,6 +77,7 @@
   #:use-module (gnu packages python)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages serialization)
   #:use-module (gnu packages telephony)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
@@ -2053,6 +2056,114 @@ supporting silence processing for automatic pause, file splitting, and
 background file post-processing.")
     (license license:gpl2+)))
 
+(define-public supercollider
+  (package
+    (name "supercollider")
+    (version "3.9.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/supercollider/supercollider"
+                    "/releases/download/Version-" version
+                    "/SuperCollider-" version "-Source-linux.tar.bz2"))
+              (sha256
+               (base32
+                "150fgnjcmb06r3pa3mbsvb4iwnqlimjwdxgbs6p55zz6g8wbln7a"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags '("-DSYSTEM_BOOST=on" "-DSYSTEM_YAMLCPP=on"
+                           "-DSC_EL=off") ;scel is packaged individually as
+                                          ;emacs-scel.
+       #:modules ((guix build utils)
+                  (guix build cmake-build-system)
+                  (ice-9 ftw))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'rm-bundled-libs
+           (lambda _
+             ;; The build system doesn't allow us to unbundle the following
+             ;; libraries.  hidapi is also heavily patched and upstream not
+             ;; actively maintained.
+             (let ((keep-dirs '("nova-simd" "nova-tt" "hidapi" "TLSF-2.4.6"
+                                "oscpack_1_1_0" "." "..")))
+               (with-directory-excursion "./external_libraries"
+                 (for-each
+                  delete-file-recursively
+                  (scandir "."
+                           (lambda (x)
+                             (and (eq? (stat:type (stat x)) 'directory)
+                                  (not (member (basename x) keep-dirs))))))))
+             #t))
+         ;; Some tests are broken (see:
+         ;; https://github.com/supercollider/supercollider/issues/3555 and
+         ;; https://github.com/supercollider/supercollider/issues/1736
+         (add-after 'rm-bundled-libs 'disable-broken-tests
+           (lambda _
+             (substitute* "testsuite/supernova/CMakeLists.txt"
+               (("server_test.cpp")
+                "")
+               (("perf_counter_test.cpp")
+                ""))
+             (delete-file "testsuite/supernova/server_test.cpp")
+             (delete-file "testsuite/supernova/perf_counter_test.cpp")
+             (substitute* "testsuite/CMakeLists.txt"
+               (("add_subdirectory\\(sclang\\)")
+                ""))
+             (delete-file "testsuite/sclang/CMakeLists.txt")
+             #t))
+         ;; TODO: Remove after version 3.9.2 is released
+         ;; (see: https://github.com/supercollider/supercollider/pull/3558).
+         (add-after 'disable-broken-tests 'apply-system-yaml-cpp-fix
+           (lambda _
+             ;; cmake: correctly include yaml-cpp (commit f82cec5ae).
+             (substitute* "editors/sc-ide/CMakeLists.txt"
+               (("external_libraries/boost\\)$")
+                "external_libraries/boost)
+include_directories(${YAMLCPP_INCLUDE_DIR})")
+               (("    yaml")
+                "    ${YAMLCPP_LIBRARY}"))
+             ;; set YAMLCPP_LIBRARY and YAMLCPP_INCLUDE_DIR if not using
+             ;; system (commit 031922987).
+             (substitute* "external_libraries/CMakeLists.txt"
+               (("set_property\\( TARGET yaml PROPERTY FOLDER 3rdparty \\)")
+                "set_property( TARGET yaml PROPERTY FOLDER 3rdparty )
+set(YAMLCPP_LIBRARY yaml)
+set(YAMLCPP_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/\
+external_libraries/yaml-cpp/include)"))
+             #t)))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("qttools" ,qttools)))
+    (inputs
+     `(("jack" ,jack-1)
+       ("libsndfile" ,libsndfile)
+       ("fftw" ,fftw)
+       ("libxt" ,libxt)
+       ("readline" ,readline)           ;readline support for sclang's CLI
+       ("alsa" ,alsa-lib)               ;for sclang's MIDI interface
+       ("eudev" ,eudev)                 ;for user interactions with devices
+       ("avahi" ,avahi)                 ;zeroconf service discovery support
+       ("icu4c" ,icu4c)
+       ("boost" ,boost)
+       ("boost-sync" ,boost-sync)
+       ("yaml-cpp" ,yaml-cpp)
+       ("qtbase" ,qtbase)               ;IDE support
+       ("qtwebkit" ,qtwebkit)
+       ("qtsensors" ,qtsensors)
+       ("qtdeclarative" ,qtdeclarative)
+       ("qtlocation" ,qtlocation)))
+    (home-page "https://github.com/supercollider/supercollider")
+    (synopsis "Synthesis engine and programming language")
+    (description "SuperCollider is a synthesis engine (@code{scsynth} or
+@code{supernova}) and programming language (@code{sclang}).  It can be used
+for experimenting with sound synthesis and algorithmic composition.
+
+SuperCollider requires jackd to be installed in your user profile and your
+user must be allowed to access the realtime features of the kernel.  Search
+for \"realtime\" in the index of the Guix manual to learn how to achieve this
+using GuixSD.")
+    (license license:gpl2+)))
+
 (define-public raul
   (package
     (name "raul")
-- 
2.16.1