about summary refs log tree commit diff
path: root/pkgs/applications/misc/actiona/default.nix
blob: 0d1500448a1406db4b1c56445653d25fca4dee42 (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
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  pkg-config,
  wrapQtAppsHook,

  bluez,
  libnotify,
  libXdmcp,
  libXtst,
  opencv,
  qtbase,
  qtmultimedia,
  qtscript,
  qttools,
  qtx11extras,
  qtxmlpatterns,

  # Running with TTS support causes the program to freeze for a few seconds every time at startup,
  # so it is disabled by default
  textToSpeechSupport ? false,
  qtspeech,
}:

let
  # For some reason qtscript wants to use the same version of qtbase as itself
  # This override makes it think that they are the same version
  qtscript' = qtscript.overrideAttrs (oldAttrs: {
    inherit (qtbase) version;
    postPatch = ''
      substituteInPlace .qmake.conf \
          --replace-fail ${oldAttrs.version} ${qtbase.version}
    '';
  });
in
stdenv.mkDerivation (finalAttrs: {
  pname = "actiona";
  version = "3.10.2";

  src = fetchFromGitHub {
    owner = "Jmgr";
    repo = "actiona";
    rev = "v${finalAttrs.version}";
    hash = "sha256-4RKCNEniBBx0kDwdHVZOqXYeGCsH8g6SfVc8JdDV0hI=";
    fetchSubmodules = true;
  };

  patches =
    [
      # Sets the proper search location for the `.so` files and the translations
      ./fix-paths.patch
    ]
    ++ lib.optionals (!textToSpeechSupport) [
      # Removes TTS support
      ./disable-tts.patch
    ];

  postPatch = ''
    substituteInPlace gui/src/mainwindow.cpp executer/src/executer.cpp tools/src/languages.cpp \
        --subst-var out
  '';

  nativeBuildInputs = [
    cmake
    pkg-config
    wrapQtAppsHook
  ];

  buildInputs = [
    bluez
    libnotify
    libXdmcp
    libXtst
    opencv
    qtbase
    qtmultimedia
    qtscript'
    qttools
    qtx11extras
    qtxmlpatterns
  ] ++ lib.optionals textToSpeechSupport [ qtspeech ];

  # RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/
  cmakeFlags = [ (lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) ];

  # udev is used by the system-actionpack
  env.NIX_LDFLAGS = "-ludev";

  installPhase = ''
    runHook preInstall

    install -Dm755 {execution,actiontools,tools}/*.so -t $out/lib
    install -Dm755 actions/actionpack*.so -t $out/lib/actions
    install -Dm755 actiona actexec -t $out/bin
    install -Dm644 translations/*.qm -t $out/share/actiona/translations
    install -Dm644 $src/actiona.desktop -t $out/share/applications
    install -Dm644 $src/gui/icons/actiona.png -t $out/share/icons/hicolor/48x48/apps

    runHook postInstall
  '';

  meta = {
    description = "A cross-platform automation tool";
    homepage = "https://github.com/Jmgr/actiona";
    license = lib.licenses.gpl3Only;
    mainProgram = "actiona";
    maintainers = with lib.maintainers; [ tomasajt ];
    platforms = lib.platforms.linux;
  };
})