about summary refs log tree commit diff
path: root/pkgs/applications/graphics/digikam/default.nix
blob: f38e402ce929fff505a77017614de67b10ace271 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
{ stdenv, fetchurl, automoc4, boost, shared_desktop_ontologies, cmake
, eigen, lcms, gettext, jasper, kdelibs, kdepimlibs, lensfun
, libgphoto2, libjpeg, libkdcraw, libkexiv2, libkipi, libpgf, libtiff
, libusb1, liblqr1, marble, mysql, opencv, perl, phonon, pkgconfig
, qca2, qimageblitz, qjson, qt4, soprano

# Optional build time dependencies
, baloo, doxygen, kfilemetadata
, lcms2
, kfaceSupport ? true, libkface ? null
, kgeomapSupport ? true, libkgeomap ? null
, libxslt

# Plugins optional build time dependencies
, gdk_pixbuf, imagemagick
, libgpod, libksane, libkvkontakte
, qt_gstreamer1 /*qt_soap, <https://github.com/commontk/QtSOAP>  herqq <http://www.herqq.org> -> is missing its av part.*/
  /*qt_koauth <http://gitorious.org/kqoauth>*/

# Supplementary packages required only by the wrapper.
, bash, kde_runtime, kde_baseapps, makeWrapper, oxygen_icons
, phonon-backend-vlc /*phonon-backend-gstreamer,*/
, ffmpegthumbs /*mplayerthumbs*/
, runCommand, shared_mime_info, writeScriptBin
}:

let 
  version = "4.12.0";
  pName = "digikam-${version}";

  build = stdenv.mkDerivation rec {
    name = "digikam-build-${version}";

    src = fetchurl {
      url = "http://download.kde.org/stable/digikam/${pName}.tar.bz2";
      sha256 = "081ldsaf3frf5khznjd3sxkjmi4dyp6w6nqnc2a0agkk0kxkl10m";
    };

    nativeBuildInputs = [ 
      automoc4 cmake gettext perl pkgconfig
    ] ++ [
      # Optional
      doxygen 
    ];

    buildInputs = [
      boost eigen jasper kdelibs kdepimlibs lcms lensfun
      libgphoto2 libjpeg libkdcraw libkexiv2 libkipi liblqr1 libpgf
      libtiff marble mysql.lib opencv phonon qca2 qimageblitz qjson qt4
      shared_desktop_ontologies soprano ]
    # Optional build time dependencies
    ++ [
      baloo 
      kfilemetadata 
      lcms2 ] 
    ++ stdenv.lib.optional (kfaceSupport && null != libkface) [ libkface ]
    ++ stdenv.lib.optional (kgeomapSupport && null != libkgeomap) [ libkgeomap ] ++ 
    [ libxslt ]
    # Plugins optional build time dependencies
    ++ [
      gdk_pixbuf imagemagick libgpod libksane
      libkvkontakte
      qt_gstreamer1 ];

    # Make digikam find some FindXXXX.cmake
    KDEDIRS="${marble}:${qjson}";

    # Find kdepimlibs's upper case headers under `include/KDE`.
    NIX_CFLAGS_COMPILE = "-I${kdepimlibs}/include/KDE";

    # Help digiKam find libusb, otherwise gphoto2 support is disabled
    cmakeFlags = [
      "-DLIBUSB_LIBRARIES=${libusb1.out}/lib"
      "-DLIBUSB_INCLUDE_DIR=${libusb1.dev}/include/libusb-1.0"
      "-DENABLE_BALOOSUPPORT=ON"
      "-DENABLE_KDEPIMLIBSSUPPORT=ON"
      "-DENABLE_LCMS2=ON" ] 
    ++ stdenv.lib.optional (kfaceSupport && null == libkface) [ "-DDIGIKAMSC_COMPILE_LIBKFACE=ON" ]
    ++ stdenv.lib.optional (kgeomapSupport && null == libkgeomap) [ "-DDIGIKAMSC_COMPILE_LIBKGEOMAP=ON" ];

    enableParallelBuilding = true;

    meta = {
      description = "Photo Management Program";
      license = stdenv.lib.licenses.gpl2;
      homepage = http://www.digikam.org;
      maintainers = with stdenv.lib.maintainers; [ goibhniu viric urkud ];
      inherit (kdelibs.meta) platforms;
    };
  };


  kdePkgs = [
    build # digikam's own build
    kdelibs kdepimlibs kde_runtime kde_baseapps libkdcraw oxygen_icons
    /*phonon-backend-gstreamer*/ phonon-backend-vlc
    ffmpegthumbs /*mplayerthumbs*/ shared_mime_info ]
  # Optional build time dependencies
  ++ [

    baloo kfilemetadata ] 
  ++ stdenv.lib.optional (kfaceSupport && null != libkface) [ libkface ]
  ++ stdenv.lib.optional (kgeomapSupport && null != libkgeomap) [ libkgeomap ] 
  ++ [ 
    libkipi ] 
  # Plugins optional build time dependencies
  ++ [
    libksane libkvkontakte
  ];


  # TODO: It should be the responsability of these packages to add themselves to `KDEDIRS`. See
  # <https://github.com/ttuegel/nixpkgs/commit/a0efeacc0ef2cf63bbb768bfb172a483307d080b> for
  # a practical example.
  # IMPORTANT: Note that using `XDG_DATA_DIRS` here instead of `KDEDIRS` won't work properly.
  KDEDIRS = with stdenv.lib; concatStrings (intersperse ":" (map (x: "${x}") kdePkgs));

  sycocaDirRelPath = "var/lib/kdesycoca";
  sycocaFileRelPath = "${sycocaDirRelPath}/${pName}.sycoca";

  sycoca = runCommand "${pName}" {

    name = "digikam-sycoca-${version}";

    nativeBuildInputs = [ kdelibs ];

    dontPatchELF = true;
    dontStrip = true;

  } ''
    # Make sure kbuildsycoca4 does not attempt to write to user home directory.
    export HOME=$PWD

    export KDESYCOCA="$out/${sycocaFileRelPath}"

    mkdir -p $out/${sycocaDirRelPath}
    export XDG_DATA_DIRS=""
    export KDEDIRS="${KDEDIRS}"
    kbuildsycoca4 --noincremental --nosignal
  '';


  replaceExeListWithWrapped = 
    let f = exeName: ''
        rm -f "$out/bin/${exeName}"
        makeWrapper "${build}/bin/${exeName}" "$out/bin/${exeName}" \
          --set XDG_DATA_DIRS "" \
          --set KDEDIRS "${KDEDIRS}" \
          --set KDESYCOCA "${sycoca}/${sycocaFileRelPath}"
      '';
    in 
      with stdenv.lib; exeNameList: concatStrings (intersperse "\n" (map f exeNameList));

in


with stdenv.lib;

/*
  Final derivation
  ----------------

   -  Create symlinks to our original build derivation items.
   -  Wrap specific executables so that they know of the appropriate
      sycoca database, `KDEDIRS` to use and block any interference
      from `XDG_DATA_DIRS` (only `dnginfo` is not wrapped).
*/
runCommand "${pName}" {
  inherit build;
  inherit sycoca;

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = kdePkgs;

  dontPatchELF = true;
  dontStrip = true;

  meta = {
    description = "Photo Management Program";
    license = stdenv.lib.licenses.gpl2;
    homepage = http://www.digikam.org;
    maintainers = with stdenv.lib.maintainers; [ /*jraygauthier*/ ];
    inherit (kdelibs.meta) platforms;
  };

} ''
  pushd $build > /dev/null
  for d in `find . -maxdepth 1 -name "*" -printf "%f\n" | tail -n+2`; do
    mkdir -p $out/$d
    for f in `find $d -maxdepth 1 -name "*" -printf "%f\n" | tail -n+2`; do
        ln -s "$build/$d/$f" "$out/$d/$f"
    done
  done
  popd > /dev/null
  
  ${replaceExeListWithWrapped [ "cleanup_digikamdb" "digitaglinktree" "digikam" "dngconverter" 
                                "expoblending" "photolayoutseditor" "scangui" "showfoto" ]}
''

/*
  
TODO
----

### Useful ###

 -  Per lib `KDELIBS` environment variable export. See above in-code TODO comment.
 -  Missing optional `qt_soap` or `herqq` (av + normal package) dependencies. Those are not
    yet (or not fully) packaged in nix. Mainly required for upnp export.
 -  Possibility to use the `phonon-backend-gstreamer` with its own user specified set of backend.
 -  Allow user to disable optional features or dependencies reacting properly.
 -  Compile `kipiplugins` as a separate package (so that it can be used by other kde packages
    and so that this package's build time is reduced).

### Not so useful ###

 -  Missing optional `qt_koauth` (not packaged in nix).
 -  Missing optional `libmediawiki` (not packaged in nix)..
 -  For some reason the cmake build does not detect `libkvkontakte`. Fix this.
 -  Possibility to use `mplayerthumbs` thumbnail creator backend. In digikam dev docs,
    it is however suggested to use `ffmpegthumbs`. Maybe we should stick to it.

*/