1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 libsndfile,
7 libsamplerate,
8 flex,
9 bison,
10 boost,
11 gettext,
12 portaudio,
13 alsa-lib ? null,
14 libpulseaudio ? null,
15 libjack2 ? null,
16 liblo ? null,
17 ladspa-sdk ? null,
18 fluidsynth ? null,
19 # , gmm ? null # opcodes don't build with gmm 5.1
20 eigen ? null,
21 curl ? null,
22 tcltk ? null,
23 fltk ? null,
24}:
25
26stdenv.mkDerivation {
27 pname = "csound";
28 version = "6.18.1-unstable-2024-07-02";
29
30 hardeningDisable = [ "format" ];
31
32 src = fetchFromGitHub {
33 owner = "csound";
34 repo = "csound";
35 rev = "2536da284dd70ec7272040cb0763f70ae57123c4";
36 sha256 = "sha256-NDYltwmjBsX1DWCjy8/4cXMSl3/mK+HaQHSKUmRR9TI=";
37 };
38
39 cmakeFlags = [
40 "-DBUILD_CSOUND_AC=0"
41 ] # fails to find Score.hpp
42 ++ lib.optional stdenv.hostPlatform.isDarwin "-DCS_FRAMEWORK_DEST=${placeholder "out"}/lib"
43 # Ignore gettext in CMAKE_PREFIX_PATH on cross to prevent find_program picking up the wrong gettext
44 ++ lib.optional (
45 stdenv.hostPlatform != stdenv.buildPlatform
46 ) "-DCMAKE_IGNORE_PATH=${lib.getBin gettext}/bin";
47
48 nativeBuildInputs = [
49 cmake
50 flex
51 bison
52 gettext
53 ];
54 buildInputs = [
55 libsndfile
56 libsamplerate
57 boost
58 ]
59 ++ lib.optionals stdenv.hostPlatform.isDarwin [
60 portaudio
61 ]
62 ++ lib.optionals stdenv.hostPlatform.isLinux (
63 builtins.filter (optional: optional != null) [
64 alsa-lib
65 libpulseaudio
66 libjack2
67 liblo
68 ladspa-sdk
69 fluidsynth
70 eigen
71 curl
72 tcltk
73 fltk
74 ]
75 );
76
77 postInstall = lib.optional stdenv.hostPlatform.isDarwin ''
78 mkdir -p $out/Library/Frameworks
79 ln -s $out/lib/CsoundLib64.framework $out/Library/Frameworks
80 '';
81
82 meta = with lib; {
83 description = "Sound design, audio synthesis, and signal processing system, providing facilities for music composition and performance on all major operating systems and platforms";
84 homepage = "https://csound.com/";
85 license = licenses.lgpl21Plus;
86 maintainers = [ maintainers.marcweber ];
87 platforms = platforms.unix;
88 broken = stdenv.hostPlatform.isDarwin;
89 };
90}