summaryrefslogtreecommitdiffstats
path: root/shell.nix
blob: 8b194f2d057c6b0442972b89611300981b5a3f9a (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{ pkgs ? (import <nixpkgs> {})
, lib ? pkgs.lib
, defaultLv2Plugins ? false
, lv2Plugins ? []
}:

let
  shell-configure = pkgs.writeShellScriptBin "configure" ''
    mkdir -p cbuild
    cd cbuild
    cmake .. "$@"
    cd ..
  '';

  shell-build = pkgs.writeShellScriptBin "build" ''
    if [ ! -d "cbuild" ]; then
      >&2 echo "First you have to run configure."
      exit 1
    fi
    cd cbuild
    cmake --build . --parallel $NIX_BUILD_CORES "$@"
    source ${pkgs.makeWrapper}/nix-support/setup-hook
    wrapProgram mixxx --prefix LV2_PATH : ${lib.makeSearchPath "lib/lv2" allLv2Plugins}
  '';

  shell-run = pkgs.writeShellScriptBin "run" ''
    if [ ! -f "cbuild/mixxx" ]; then
      >&2 echo "First you have to run build."
      exit 1
    fi
    cd cbuild
    ./mixxx --resourcePath res/ "$@"
  '';

  shell-debug = pkgs.writeShellScriptBin "debug" ''
    if [ ! -f "cbuild/mixxx" ]; then
      >&2 echo "First you have to run build."
      exit 1
    fi
    cd cbuild
    LV2_PATH=${lib.makeSearchPath "lib/lv2" allLv2Plugins} gdb --args ./.mixxx-wrapped --resourcePath res/ "$@"
  '';

  allLv2Plugins = lv2Plugins ++ (lib.optionals defaultLv2Plugins (with pkgs; [
    artyFX
    infamousPlugins
    mod-distortion
    rkrlv2
    x42-plugins
    zam-plugins
  ]));

in pkgs.mkShell rec {
  buildInputs = with pkgs; [
    ccache
    chromaprint
    clang-tools
    cmake
    ffmpeg
    fftw
    flac
    gdb
    git
    glib
    hidapi
    lame
    libGLU
    libebur128
    libid3tag
    libmad
    libmodplug
    libopus
    libsForQt5
    libselinux
    libsepol
    libshout
    libsndfile
    libusb1
    libvorbis
    lilv
    lv2
    mp4v2
    opusfile
    pcre
    pkgconfig
    portaudio
    portmidi
    protobuf
    qt5
    rubberband
    soundtouch
    sqlite
    taglib
    upower
    utillinux
    vamp
    wavpack
    x11

    shell-configure
    shell-build
    shell-run
    shell-debug
    allLv2Plugins
  ];

  # SOURCE_DATE_EPOCH helps with python and pre-commit hook
  shellHook =  ''
    export PYTHONPATH=venv/lib/python3.7/site-packages/:$PYTHONPATH
    export SOURCE_DATE_EPOCH=315532800
    echo -e "Mixxx development shell. Available commands:\n"
    echo " configure - configures cmake (only has to run once)"
    echo " build - compiles Mixxx"
    echo " run - runs Mixxx with development settings"
    echo " debug - runs Mixxx inside gdb"
  '';
}