about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/audio/vcv-rack/default.nix
blob: 234b98a893c853845279b144878b7eb422504dfe (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
79
80
81
82
83
84
{ stdenv, makeWrapper, fetchFromBitbucket, fetchFromGitHub, pkgconfig
, alsaLib, curl, glew, glfw, gtk2-x11, jansson, libjack2, libXext, libXi
, libzip, rtaudio, rtmidi, speex }:

let
  glfw-git = glfw.overrideAttrs (oldAttrs: rec {
    name = "glfw-git-${version}";
    version = "2019-06-30";
    src = fetchFromGitHub {
      owner = "AndrewBelt";
      repo = "glfw";
      rev = "d9ab59efc781c392128a449361a381fcc93cf6f3";
      sha256 = "1ykkq6qq8y6j5hlfj2zp1p87kr33vwhywziprz20v5avx1q7rjm8";
    };
    # We patch the source to export a function that was added to the glfw fork
    # for Rack so it is present when we build glfw as a shared library.
    # See https://github.com/AndrewBelt/glfw/pull/1 for discussion of this issue
    # with upstream.
    patches = [ ./glfw.patch ];
    buildInputs = oldAttrs.buildInputs ++ [ libXext libXi ];
  });
  pfft-source = fetchFromBitbucket {
    owner = "jpommier";
    repo = "pffft";
    rev = "29e4f76ac53bef048938754f32231d7836401f79";
    sha256 = "084csgqa6f1a270bhybjayrh3mpyi2jimc87qkdgsqcp8ycsx1l1";
  };
in
with stdenv.lib; stdenv.mkDerivation rec {
  pname = "VCV-Rack";
  version = "1.1.4";

  src = fetchFromGitHub {
    owner = "VCVRack";
    repo = "Rack";
    rev = "v${version}";
    sha256 = "04kg0nm7w19s2zfrsxjfl3bs4sy3bzf28kzl4hayzwv480667ybx";
    fetchSubmodules = true;
  };

  patches = [ ./rack-minimize-vendoring.patch ];

  prePatch = ''
    cp -r ${pfft-source} dep/jpommier-pffft-source

    mkdir -p dep/include

    cp dep/jpommier-pffft-source/*.h dep/include
    cp dep/nanosvg/**/*.h dep/include
    cp dep/nanovg/src/*.h dep/include
    cp dep/osdialog/*.h dep/include
    cp dep/oui-blendish/*.h dep/include

    substituteInPlace include/audio.hpp --replace "<RtAudio.h>" "<rtaudio/RtAudio.h>"
    substituteInPlace compile.mk --replace "-march=nocona" ""
  '';

  enableParallelBuilding = true;

  nativeBuildInputs = [ makeWrapper pkgconfig ];
  buildInputs = [ glfw-git alsaLib curl glew gtk2-x11 jansson libjack2 libzip rtaudio rtmidi speex ];

  buildFlags = "Rack";

  installPhase = ''
    install -D -m755 -t $out/bin Rack

    mkdir -p $out/share/vcv-rack
    cp -r res Core.json template.vcv LICENSE* cacert.pem $out/share/vcv-rack

    # Override the default global resource file directory
    wrapProgram $out/bin/Rack --add-flags "-s $out/share/vcv-rack"
  '';

  meta = with stdenv.lib; {
    description = "Open-source virtual modular synthesizer";
    homepage = http://vcvrack.com/;
    # The source is BSD-3 licensed, some of the art is CC-BY-NC 4.0 or under a
    # no-derivatives clause
    license = with licenses; [ bsd3 cc-by-nc-40 unfreeRedistributable ];
    maintainers = with maintainers; [ moredread nathyong ];
    platforms = platforms.linux;
  };
}