1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 pkg-config,
7 util-linux,
8 libselinux,
9 libsepol,
10 lerc,
11 libthai,
12 libdatrie,
13 libxkbcommon,
14 libepoxy,
15 libXtst,
16 wrapGAppsHook3,
17 makeWrapper,
18 pixman,
19 libpthreadstubs,
20 gtkmm3,
21 libXau,
22 libXdmcp,
23 lcms2,
24 libiptcdata,
25 fftw,
26 expat,
27 pcre2,
28 libsigcxx,
29 lensfun,
30 librsvg,
31 libcanberra-gtk3,
32 gtk-mac-integration,
33 exiv2,
34 libraw,
35 libjxl,
36}:
37
38stdenv.mkDerivation rec {
39 pname = "rawtherapee";
40 version = "5.12";
41
42 src = fetchFromGitHub {
43 owner = "RawTherapee";
44 repo = "RawTherapee";
45 tag = version;
46 hash = "sha256-h8eWnw9I1R0l9WAI/DylsdA241qU9NhYGEPYz+JlE18=";
47 # The developers ask not to use the tarball from Github releases, see
48 # https://www.rawtherapee.com/downloads/5.10/#news-relevant-to-package-maintainers
49 forceFetchGit = true;
50 };
51
52 postPatch = ''
53 cat <<EOF > ReleaseInfo.cmake
54 set(GIT_DESCRIBE ${version})
55 set(GIT_BRANCH ${version})
56 set(GIT_VERSION ${version})
57 # Missing GIT_COMMIT and GIT_COMMIT_DATE, which are not easy to obtain.
58 set(GIT_COMMITS_SINCE_TAG 0)
59 set(GIT_COMMITS_SINCE_BRANCH 0)
60 set(GIT_VERSION_NUMERIC_BS ${version})
61 EOF
62 substituteInPlace tools/osx/Info.plist.in rtgui/config.h.in \
63 --replace "/Applications" "${placeholder "out"}/Applications"
64 '';
65
66 nativeBuildInputs = [
67 cmake
68 pkg-config
69 wrapGAppsHook3
70 ]
71 ++ lib.optionals stdenv.hostPlatform.isDarwin [
72 makeWrapper
73 ];
74
75 buildInputs = [
76 util-linux
77 libselinux
78 libsepol
79 lerc
80 libthai
81 libdatrie
82 libxkbcommon
83 libepoxy
84 libXtst
85 pixman
86 libpthreadstubs
87 gtkmm3
88 libXau
89 libXdmcp
90 lcms2
91 libiptcdata
92 fftw
93 expat
94 pcre2
95 libsigcxx
96 lensfun
97 librsvg
98 exiv2
99 libraw
100 libjxl
101 ]
102 ++ lib.optionals stdenv.hostPlatform.isLinux [
103 libcanberra-gtk3
104 ]
105 ++ lib.optionals stdenv.hostPlatform.isDarwin [
106 gtk-mac-integration
107 ];
108
109 cmakeFlags = [
110 "-DPROC_TARGET_NUMBER=2"
111 "-DCACHE_NAME_SUFFIX=\"\""
112 "-DWITH_SYSTEM_LIBRAW=\"ON\""
113 "-DWITH_JXL=\"ON\""
114 ]
115 ++ lib.optionals stdenv.hostPlatform.isDarwin [
116 "-DCMAKE_OSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}"
117 ];
118
119 CMAKE_CXX_FLAGS = toString [
120 "-std=c++11"
121 "-Wno-deprecated-declarations"
122 "-Wno-unused-result"
123 ];
124 env.CXXFLAGS = "-include cstdint"; # needed at least with gcc13 on aarch64-linux
125
126 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
127 mkdir -p $out/Applications/RawTherapee.app $out/bin
128 cp -R Release $out/Applications/RawTherapee.app/Contents
129 for f in $out/Applications/RawTherapee.app/Contents/MacOS/*; do
130 makeWrapper $f $out/bin/$(basename $f)
131 done
132 '';
133
134 meta = {
135 description = "RAW converter and digital photo processing software";
136 homepage = "http://www.rawtherapee.com/";
137 license = lib.licenses.gpl3Plus;
138 maintainers = with lib.maintainers; [
139 jcumming
140 mahe
141 ];
142 platforms = with lib.platforms; unix;
143 };
144}