about summary refs log tree commit diff
path: root/pkgs/development/interpreters/supercollider/default.nix
blob: 344d00703164022e52b6fcce92a12c56b94ed951 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ lib, stdenv, mkDerivation, fetchurl, cmake, runtimeShell
, pkg-config, alsa-lib, libjack2, libsndfile, fftw
, curl, gcc, libXt, qtbase, qttools, qtwebengine
, readline, qtwebsockets, useSCEL ? false, emacs
, gitUpdater, supercollider-with-plugins
, supercolliderPlugins, writeText, runCommand
}:

mkDerivation rec {
  pname = "supercollider";
  version = "3.13.0";

  src = fetchurl {
    url = "https://github.com/supercollider/supercollider/releases/download/Version-${version}/SuperCollider-${version}-Source.tar.bz2";
    sha256 = "sha256-D8Xbpbrq43+Qaa0oiFqkBcaiUwnjiGy+ERvTt8BVMc4=";
  };

  patches = [
    # add support for SC_DATA_DIR and SC_PLUGIN_DIR env vars to override compile-time values
    ./supercollider-3.12.0-env-dirs.patch
  ];

  postPatch = ''
    substituteInPlace common/sc_popen.cpp --replace '/bin/sh' '${runtimeShell}'
  '';

  strictDeps = true;

  nativeBuildInputs = [ cmake pkg-config qttools ];

  buildInputs = [ gcc libjack2 libsndfile fftw curl libXt qtbase qtwebengine qtwebsockets readline ]
    ++ lib.optional (!stdenv.hostPlatform.isDarwin) alsa-lib
    ++ lib.optional useSCEL emacs;

  hardeningDisable = [ "stackprotector" ];

  cmakeFlags = [
    "-DSC_WII=OFF"
    "-DSC_EL=${if useSCEL then "ON" else "OFF"}"
  ];

  passthru = {
    updateScript = gitUpdater {
      url = "https://github.com/supercollider/supercollider.git";
      rev-prefix = "Version-";
      ignoredVersions = "rc|beta";
    };

    tests = {
      # test to make sure sclang runs and included plugins are successfully found
      sclang-sc3-plugins = let
        supercollider-with-test-plugins = supercollider-with-plugins.override {
          plugins = with supercolliderPlugins; [ sc3-plugins ];
        };
        testsc = writeText "test.sc" ''
          var err = 0;
          try {
          MdaPiano.name.postln;
          } {
          err = 1;
          };
          err.exit;
        '';
      in runCommand "sclang-sc3-plugins-test" { } ''
        timeout 60s env XDG_CONFIG_HOME="$(mktemp -d)" QT_QPA_PLATFORM=minimal ${supercollider-with-test-plugins}/bin/sclang ${testsc} >$out
      '';
    };
  };

  meta = with lib; {
    description = "Programming language for real time audio synthesis";
    homepage = "https://supercollider.github.io";
    changelog = "https://github.com/supercollider/supercollider/blob/Version-${version}/CHANGELOG.md";
    maintainers = [ ];
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
  };
}