1{ lib, stdenv, mkDerivation, fetchurl, cmake, runtimeShell
2, pkg-config, alsa-lib, libjack2, libsndfile, fftw
3, curl, gcc, libXt, qtbase, qttools, qtwebengine
4, readline, qtwebsockets, useSCEL ? false, emacs
5, gitUpdater, supercollider-with-plugins
6, supercolliderPlugins, writeText, runCommand
7}:
8
9mkDerivation rec {
10 pname = "supercollider";
11 version = "3.13.0";
12
13 src = fetchurl {
14 url = "https://github.com/supercollider/supercollider/releases/download/Version-${version}/SuperCollider-${version}-Source.tar.bz2";
15 sha256 = "sha256-D8Xbpbrq43+Qaa0oiFqkBcaiUwnjiGy+ERvTt8BVMc4=";
16 };
17
18 patches = [
19 # add support for SC_DATA_DIR and SC_PLUGIN_DIR env vars to override compile-time values
20 ./supercollider-3.12.0-env-dirs.patch
21 ];
22
23 postPatch = ''
24 substituteInPlace common/sc_popen.cpp --replace '/bin/sh' '${runtimeShell}'
25 '';
26
27 strictDeps = true;
28
29 nativeBuildInputs = [ cmake pkg-config qttools ];
30
31 buildInputs = [ gcc libjack2 libsndfile fftw curl libXt qtbase qtwebengine qtwebsockets readline ]
32 ++ lib.optional (!stdenv.isDarwin) alsa-lib
33 ++ lib.optional useSCEL emacs;
34
35 hardeningDisable = [ "stackprotector" ];
36
37 cmakeFlags = [
38 "-DSC_WII=OFF"
39 "-DSC_EL=${if useSCEL then "ON" else "OFF"}"
40 ];
41
42 passthru = {
43 updateScript = gitUpdater {
44 url = "https://github.com/supercollider/supercollider.git";
45 rev-prefix = "Version-";
46 ignoredVersions = "rc|beta";
47 };
48
49 tests = {
50 # test to make sure sclang runs and included plugins are successfully found
51 sclang-sc3-plugins = let
52 supercollider-with-test-plugins = supercollider-with-plugins.override {
53 plugins = with supercolliderPlugins; [ sc3-plugins ];
54 };
55 testsc = writeText "test.sc" ''
56 var err = 0;
57 try {
58 MdaPiano.name.postln;
59 } {
60 err = 1;
61 };
62 err.exit;
63 '';
64 in runCommand "sclang-sc3-plugins-test" { } ''
65 timeout 60s env XDG_CONFIG_HOME="$(mktemp -d)" QT_QPA_PLATFORM=minimal ${supercollider-with-test-plugins}/bin/sclang ${testsc} >$out
66 '';
67 };
68 };
69
70 meta = with lib; {
71 description = "Programming language for real time audio synthesis";
72 homepage = "https://supercollider.github.io";
73 changelog = "https://github.com/supercollider/supercollider/blob/Version-${version}/CHANGELOG.md";
74 maintainers = with maintainers; [ lilyinstarlight ];
75 license = licenses.gpl3Plus;
76 platforms = platforms.linux;
77 };
78}