summaryrefslogtreecommitdiffstats
path: root/default.nix
blob: 6db0ec8a675040781bea532ade1994d9c357f70a (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
{ nixroot  ? (import <nixpkgs> {}) }:
let inherit (nixroot) stdenv pkgs lib
    chromaprint fftw flac libid3tag libmad libopus libshout libsndfile lilv 
    libusb1 libvorbis libebur128 pkgconfig portaudio portmidi protobuf qt5 glib
    rubberband scons sqlite taglib soundtouch vamp opusfile hidapi upower ccache git
    libGLU x11 lame lv2 makeWrapper;

  shell-build = nixroot.writeShellScriptBin "build" ''
    scons \
      -j$NIX_BUILD_CORES \
      $sconsFlags "prefix=$HOME/mixxx" "$@";
  '';

  shell-run = nixroot.writeShellScriptBin "run" ''
      BUILDDIR=$(ls -1 -d -t lin64_build lin_build | head -1)
      $BUILDDIR/mixxx --settingsPath ./devsettings/ --resourcePath ./res "$@"
  '';

in stdenv.mkDerivation rec {
  name = "mixxx-${version}";
  # reading the version from git output is very hard to do without wasting lots of diskspace and runtime
  # reading version file is easy
  version = lib.strings.removeSuffix "\"\n" (
              lib.strings.removePrefix "#define MIXXX_VERSION \"" (
                builtins.readFile ./src/_version.h ));

  shellHook =  ''
    export CC="ccache gcc"
    export CXX="ccache g++"

    echo -e "mixxx development shell. available commands:\n"
    echo " build - compiles mixxx"
    echo " run - runs mixxx with development settings"
      '';

  src = builtins.filterSource
     (path: type: ! builtins.any (x: x == baseNameOf path) [ ".git" "cache" "lin64_build" "lin_build" "debian" ])
     ./.;

  nativeBuildInputs = [
    shell-build shell-run
  ];

  buildInputs = [
    chromaprint fftw flac libid3tag libmad libopus libshout libsndfile
    libusb1 libvorbis libebur128 pkgconfig portaudio portmidi protobuf qt5.full
    rubberband scons sqlite taglib soundtouch vamp.vampSDK opusfile upower hidapi
    ccache git glib x11 libGLU lilv lame lv2 makeWrapper qt5.qtbase
  ];

  sconsFlags = [
    "build=debug"
    "qtdir=${qt5.full}"
  ];

  buildPhase = ''
    runHook preBuild;
    mkdir -p "$out";
    scons \
      -j$NIX_BUILD_CORES \
      $sconsFlags "prefix=$out";
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    scons $sconsFlags "prefix=$out" install
    wrapProgram $out/bin/mixxx --suffix QT_PLUGIN_PATH : ${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix} --set QTDIR ${qt5.full}
    runHook postInstall
  '';

  meta = with nixroot.stdenv.lib; {
    homepage = https://mixxx.org;
    description = "Digital DJ mixing software";
    license = licenses.gpl2Plus;
    maintainers = [ maintainers.aszlig maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}