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