about summary refs log tree commit diff
path: root/pkgs/by-name/di/digikam/package.nix
blob: 1454eae6717aa5c550f961e83275f507b24ba253 (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
{
  stdenv,
  config,
  lib,
  fetchFromGitLab,
  fetchgit,

  cmake,
  ninja,
  extra-cmake-modules,
  flex,
  bison,
  wrapGAppsHook3,

  opencv,
  libtiff,
  libpng,
  libjpeg,
  libheif,
  libjxl,
  boost,
  lcms2,
  expat,
  exiv2,
  libxml2,
  libxslt,
  ffmpeg,
  jasper,
  eigen,
  lensfun,
  liblqr1,
  libgphoto2,
  libusb1,
  imagemagick,
  x265,
  libGLX,
  libGLU,

  kdePackages,

  # For `digitaglinktree`
  perl,
  sqlite,

  runtimeShell,
  # For panorama and focus stacking
  enblend-enfuse,
  hugin,
  gnumake,
}:

let
  testData = fetchgit {
    url = "https://invent.kde.org/graphics/digikam-test-data.git";
    rev = "d02dd20b23cc279792325a0f03d21688547a7a59";
    fetchLFS = true;
    hash = "sha256-SvsmcniDRorwu9x9OLtHD9ftgquyoE5Kl8qDgqi1XdQ=";
  };
in

stdenv.mkDerivation (finalAttrs: {
  pname = "digikam";
  version = "8.4.0";

  src = fetchFromGitLab {
    domain = "invent.kde.org";
    owner = "graphics";
    repo = "digikam";
    rev = "v${finalAttrs.version}";
    hash = "sha256-GJYlxJkvFEXppVk0yC9ojszylfAGt3eBMAjNUu60XDY=";
  };

  patches = [ ./disable-tests-download.patch ];

  strictDeps = true;

  nativeBuildInputs = [
    cmake
    ninja
    extra-cmake-modules
    flex
    bison
    kdePackages.wrapQtAppsHook
    wrapGAppsHook3
  ];

  # Based on <https://www.digikam.org/api/index.html#externaldeps>,
  # but it doesn’t have everything, so you also have to check the
  # CMake files…
  #
  # We list non‐Qt dependencies first to override Qt’s propagated
  # build inputs.

  buildInputs = [
    opencv
    libtiff
    libpng
    # TODO: Figure out how on earth to get it to pick up libjpeg8 for
    # lossy DNG support.
    libjpeg
    libheif
    libjxl
    boost
    lcms2
    expat
    exiv2
    libxml2
    libxslt
    # Qt WebEngine uses and propagates FFmpeg, and if it’s a
    # different version it causes linker warnings.
    #ffmpeg
    jasper
    eigen
    lensfun
    liblqr1
    libgphoto2
    libusb1
    imagemagick
    x265
    libGLX
    libGLU

    kdePackages.qtbase
    kdePackages.qtnetworkauth
    kdePackages.qtscxml
    kdePackages.qtsvg
    kdePackages.qtwebengine
    kdePackages.qt5compat
    kdePackages.qtmultimedia

    kdePackages.kconfig
    kdePackages.kxmlgui
    kdePackages.ki18n
    kdePackages.kwindowsystem
    kdePackages.kservice
    kdePackages.solid
    kdePackages.kcoreaddons
    kdePackages.knotifyconfig
    kdePackages.knotifications
    kdePackages.threadweaver
    kdePackages.kiconthemes
    kdePackages.kfilemetadata
    kdePackages.kcalendarcore
    kdePackages.kio
    kdePackages.sonnet
    # libksane and akonadi-contacts do not yet work when building for
    # Qt 6.
  ];

  checkInputs = [ kdePackages.qtdeclarative ];

  postConfigure = lib.optionalString finalAttrs.doCheck ''
    ln -s ${testData} $cmakeDir/test-data
  '';

  postPatch = ''
    substituteInPlace \
      core/dplugins/bqm/custom/userscript/userscript.cpp \
      core/utilities/import/backend/cameracontroller.cpp \
      --replace-fail '"/bin/bash"' ${lib.escapeShellArg "\"${runtimeShell}\""}
  '';

  cmakeFlags = [
    (lib.cmakeBool "BUILD_WITH_QT6" true)
    (lib.cmakeBool "ENABLE_KFILEMETADATASUPPORT" true)
    #(lib.cmakeBool "ENABLE_AKONADICONTACTSUPPORT" true)
    (lib.cmakeBool "ENABLE_MEDIAPLAYER" true)
    (lib.cmakeBool "ENABLE_APPSTYLES" true)
  ];

  # Tests segfault for some reason…
  # TODO: Get them working.
  doCheck = false;

  dontWrapGApps = true;

  preFixup = ''
    qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
    qtWrapperArgs+=(--prefix PATH : ${
      lib.makeBinPath [
        gnumake
        hugin
        enblend-enfuse
      ]
    })
    qtWrapperArgs+=(--suffix DK_PLUGIN_PATH : ${placeholder "out"}/${kdePackages.qtbase.qtPluginPrefix}/digikam)
    substituteInPlace $out/bin/digitaglinktree \
      --replace "/usr/bin/perl" "${perl}/bin/perl" \
      --replace "/usr/bin/sqlite3" "${sqlite}/bin/sqlite3"
  '';

  meta = {
    description = "Photo management application";
    homepage = "https://www.digikam.org/";
    changelog = "${finalAttrs.src.meta.homepage}-/blob/master/project/NEWS.${finalAttrs.version}";
    sourceProvenance = [ lib.sourceTypes.fromSource ];
    license = lib.licenses.gpl2Plus;
    maintainers = [ ];
    platforms = lib.platforms.linux;
    mainProgram = "digikam";
  };
})