1{
2 stdenv,
3 lib,
4 DarwinTools,
5 alsa-utils,
6 at-spi2-core,
7 cmake,
8 curl,
9 dbus,
10 elfutils,
11 fetchFromGitHub,
12 flac,
13 gitMinimal,
14 wrapGAppsHook3,
15 glew,
16 gtest,
17 jasper,
18 lame,
19 libGLU,
20 libarchive,
21 libdatrie,
22 libepoxy,
23 libexif,
24 libogg,
25 libopus,
26 libselinux,
27 libsepol,
28 libsndfile,
29 libthai,
30 libunarr,
31 libusb1,
32 libvorbis,
33 libxkbcommon,
34 lsb-release,
35 lz4,
36 libmpg123,
37 makeWrapper,
38 pkg-config,
39 portaudio,
40 rapidjson,
41 sqlite,
42 tinyxml,
43 util-linux,
44 wxGTK32,
45 xorg,
46 xz,
47}:
48
49stdenv.mkDerivation (finalAttrs: {
50 pname = "opencpn";
51 version = "5.10.2";
52
53 src = fetchFromGitHub {
54 owner = "OpenCPN";
55 repo = "OpenCPN";
56 rev = "Release_${finalAttrs.version}";
57 hash = "sha256-VuMClQ5k1mTMF5yWstTi9YTF4tEN68acH5OPhjdzIwM=";
58 };
59
60 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
61 sed -i '/fixup_bundle/d; /NO_DEFAULT_PATH/d' CMakeLists.txt
62 '';
63
64 nativeBuildInputs = [
65 cmake
66 pkg-config
67 gtest
68 wrapGAppsHook3
69 ]
70 ++ lib.optionals stdenv.hostPlatform.isLinux [
71 lsb-release
72 ]
73 ++ lib.optionals stdenv.hostPlatform.isDarwin [
74 DarwinTools
75 makeWrapper
76 ];
77
78 buildInputs = [
79 at-spi2-core
80 curl
81 dbus
82 flac
83 gitMinimal
84 ]
85 ++ [
86 glew
87 jasper
88 libGLU
89 libarchive
90 libdatrie
91 libepoxy
92 libexif
93 libogg
94 libopus
95 libsndfile
96 libthai
97 libunarr
98 libusb1
99 libvorbis
100 libxkbcommon
101 lz4
102 libmpg123
103 portaudio
104 rapidjson
105 sqlite
106 tinyxml
107 wxGTK32
108 xz
109 ]
110 ++ lib.optionals stdenv.hostPlatform.isLinux [
111 alsa-utils
112 libselinux
113 libsepol
114 util-linux
115 xorg.libXdmcp
116 xorg.libXtst
117 ]
118 ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [
119 elfutils
120 ]
121 ++ lib.optionals stdenv.hostPlatform.isDarwin [
122 lame
123 ];
124
125 cmakeFlags = [
126 "-DOCPN_BUNDLE_DOCS=true"
127 ]
128 ++ lib.optionals stdenv.hostPlatform.isLinux [
129 # Override OpenCPN platform detection.
130 "-DOCPN_TARGET_TUPLE=unknown;unknown;${stdenv.hostPlatform.linuxArch}"
131 ];
132
133 env.NIX_CFLAGS_COMPILE = toString (
134 lib.optionals (!stdenv.hostPlatform.isx86) [
135 "-DSQUISH_USE_SSE=0"
136 ]
137 );
138
139 postInstall = lib.optionals stdenv.hostPlatform.isDarwin ''
140 mkdir -p $out/Applications
141 mv $out/bin/OpenCPN.app $out/Applications
142 makeWrapper $out/Applications/OpenCPN.app/Contents/MacOS/OpenCPN $out/bin/opencpn
143 '';
144
145 doCheck = true;
146
147 meta = with lib; {
148 description = "Concise ChartPlotter/Navigator";
149 maintainers = with maintainers; [
150 kragniz
151 lovesegfault
152 ];
153 platforms = platforms.unix;
154 license = licenses.gpl2Plus;
155 homepage = "https://opencpn.org/";
156 };
157})