summary refs log tree commit diff
path: root/pkgs/applications/graphics/screencloud/default.nix
blob: 11e37c4bf649d48b2e6ca8606a074a10db810283 (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
{ stdenv, fetchFromGitHub, cmake, qt4, quazip, qt-mobility, qxt, pythonPackages }:

with stdenv.lib;
stdenv.mkDerivation rec {
  pname = "screencloud";
  version = "1.2.0";

  # API Keys. According to the author of the AUR package, these are only used
  # for tracking usage.
  consumerKey = "23e747012c68601f27ab69c6de129ed70552d55b6";
  consumerSecret = "4701cb00c1bd357bbcae7c3d713dd216";
  
  src = fetchFromGitHub {
    owner = "olav-st";
    repo = "screencloud";
    rev = "v${version}";
    sha256 = "1s0dxa1sa37nvna5nfqdsp294810favj68qb7ghl78qna7zw0cim";
  };

  buildInputs = [ cmake qt4 quazip qt-mobility qxt pythonPackages.python pythonPackages.pycrypto ];

  patchPhase = ''
    # Required to make the configure script work. Normally, screencloud's
    # CMakeLists file sets the install prefix to /opt by force. This is stupid
    # and breaks nix, so we force it to install where we want. Please don't
    # write CMakeLists files like this, as things like this are why we can't
    # have nice things.
    substituteInPlace "CMakeLists.txt" --replace "set(CMAKE_INSTALL_PREFIX \"/opt\")" ""
  '';

  enableParallelBuilding = true;

  # We need to append /opt to our CMAKE_INSTALL_PREFIX, so we tell the Nix not
  # to add the argument for us.
  dontAddPrefix = true;

  cmakeFlags = [
    "-DQXT_QXTCORE_INCLUDE_DIR=${qxt}/include/QxtCore"
    "-DQXT_QXTCORE_LIB_RELEASE=${qxt}/lib/libQxtCore.so"
    "-DQXT_QXTGUI_INCLUDE_DIR=${qxt}/include/QxtGui"
    "-DQXT_QXTGUI_LIB_RELEASE=${qxt}/lib/libQxtGui.so"
    "-DCONSUMER_KEY_SCREENCLOUD=${consumerKey}"
    "-DCONSUMER_SECRET_SCREENCLOUD=${consumerSecret}"
  ];

  setSourceRoot = ''
    sourceRoot=$(echo */screencloud)
  '';

  preConfigure = ''
    # This needs to be set in preConfigure instead of cmakeFlags in order to
    # access the $prefix environment variable.
    export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix/opt $cmakeFlags"
  '';

  # There are a number of issues with screencloud's installation. We need to add
  # pycrypto to the PYTHONPATH so that the SFTP plugin will work properly; and
  # we need to move the libPythonQt library into a folder where it can actually
  # be found.
  postInstall = ''
    patchShebangs $prefix/opt/screencloud/screencloud.sh
    substituteInPlace "$prefix/opt/screencloud/screencloud.sh" --replace "/opt" "$prefix/opt"
    sed -i "2 i\export PYTHONPATH=$(toPythonPath ${pythonPackages.pycrypto}):\$PYTHONPATH" "$prefix/opt/screencloud/screencloud.sh"
    mkdir $prefix/bin
    mkdir $prefix/lib
    ln -s $prefix/opt/screencloud/screencloud.sh $prefix/bin/screencloud
    ln -s $prefix/opt/screencloud/libPythonQt.so $prefix/lib/libPythonQt.so
  '';

  meta = {
    homepage = "https://screencloud.net/";
    description = "Client for Screencloud, an easy to use screenshot sharing tool";
    license = stdenv.lib.licenses.gpl2;
    maintainers = with stdenv.lib.maintainers; [ forkk ];
    platforms = with stdenv.lib.platforms; linux;
  };
}