summary refs log tree commit diff
path: root/pkgs/applications/misc/golden-cheetah/default.nix
blob: dde1c32e805f79ea43781a63b474c6a5f4a92ee5 (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
{ stdenv, fetchFromGitHub, mkDerivation
, qtbase, qtsvg, qtserialport, qtwebengine, qtmultimedia, qttools
, qtconnectivity, qtcharts, libusb
, yacc, flex, zlib, qmake, makeDesktopItem, makeWrapper
}:

let
  desktopItem = makeDesktopItem {
    name = "goldencheetah";
    exec = "GoldenCheetah";
    icon = "goldencheetah";
    desktopName = "GoldenCheetah";
    genericName = "GoldenCheetah";
    comment = "Performance software for cyclists, runners and triathletes";
    categories = "Application;Utility;";
  };
in mkDerivation rec {
  pname = "golden-cheetah";
  version = "3.5-RC2X";

  src = fetchFromGitHub {
    owner = "GoldenCheetah";
    repo = "GoldenCheetah";
    rev = "V${version}";
    sha256 = "1d85700gjbcw2badwz225rjdr954ai89900vp8sal04sk79wbr6g";
  };

  buildInputs = [
    qtbase qtsvg qtserialport qtwebengine qtmultimedia qttools zlib
    qtconnectivity qtcharts libusb
  ];
  nativeBuildInputs = [ flex makeWrapper qmake yacc ];

  NIX_LDFLAGS = [ "-lz" ];

  qtWrapperArgs = [ "--set LD_LIBRARY_PATH ${zlib.out}/lib" ];

  preConfigure = ''
    cp src/gcconfig.pri.in src/gcconfig.pri
    cp qwt/qwtconfig.pri.in qwt/qwtconfig.pri
    echo 'QMAKE_LRELEASE = ${qttools.dev}/bin/lrelease' >> src/gcconfig.pri
    echo 'LIBUSB_INSTALL = ${libusb}' >> src/gcconfig.pri
    echo 'LIBUSB_INCLUDE = ${libusb.dev}/include' >> src/gcconfig.pri
    echo 'LIBUSB_LIBS = -L${libusb}/lib -lusb' >> src/gcconfig.pri
    sed -i -e '21,23d' qwt/qwtconfig.pri # Removed forced installation to /usr/local

    # Use qtwebengine instead of qtwebkit
    substituteInPlace src/gcconfig.pri \
      --replace "#DEFINES += NOWEBKIT" "DEFINES += NOWEBKIT"
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp src/GoldenCheetah $out/bin
    install -Dm644 "${desktopItem}/share/applications/"* -t $out/share/applications/
    install -Dm644 src/Resources/images/gc.png $out/share/pixmaps/goldencheetah.png

    runHook postInstall
  '';

  meta = with stdenv.lib; {
    description = "Performance software for cyclists, runners and triathletes";
    platforms = platforms.linux;
    maintainers = [ maintainers.ocharles ];
    license = licenses.gpl3;
  };
}