nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 autoreconfHook,
6 writeShellScriptBin,
7 cmake,
8 wrapQtAppsHook,
9 pkg-config,
10 qmake,
11 curl,
12 grantlee,
13 hidapi,
14 libgit2,
15 libssh2,
16 libusb1,
17 libxml2,
18 libxslt,
19 libzip,
20 zlib,
21 qtbase,
22 qtconnectivity,
23 qtlocation,
24 qtsvg,
25 qttools,
26 qtwebengine,
27 libXcomposite,
28 bluez,
29 writeScript,
30}:
31
32let
33 version = "6.0.5231";
34
35 subsurfaceSrc = (
36 fetchFromGitHub {
37 owner = "Subsurface";
38 repo = "subsurface";
39 rev = "38a0050ac33566dfd34bf94cf1d7ac66034e4118";
40 hash = "sha256-6fNcBF/Ep2xs2z83ZQ09XNb/ZkhK1nUNLChV1x8qh0Y=";
41 fetchSubmodules = true;
42 }
43 );
44
45 libdc = stdenv.mkDerivation {
46 pname = "libdivecomputer-ssrf";
47 inherit version;
48
49 src = subsurfaceSrc;
50
51 sourceRoot = "${subsurfaceSrc.name}/libdivecomputer";
52
53 nativeBuildInputs = [
54 autoreconfHook
55 pkg-config
56 ];
57
58 buildInputs = [
59 zlib
60 libusb1
61 bluez
62 hidapi
63 ];
64
65 enableParallelBuilding = true;
66
67 meta = with lib; {
68 homepage = "https://www.libdivecomputer.org";
69 description = "Cross-platform and open source library for communication with dive computers from various manufacturers";
70 maintainers = with maintainers; [ mguentner ];
71 license = licenses.lgpl21;
72 platforms = platforms.all;
73 };
74 };
75
76 googlemaps = stdenv.mkDerivation rec {
77 pname = "googlemaps";
78 version = "0.0.0.2";
79
80 src = fetchFromGitHub {
81 owner = "vladest";
82 repo = "googlemaps";
83 rev = "v.${version}";
84 hash = "sha256-PfSLFQeCeVNcCVDCZehxyNLQGT6gff5jNxMW8lAaP8c=";
85 };
86
87 nativeBuildInputs = [ qmake ];
88
89 buildInputs = [
90 qtbase
91 qtlocation
92 libXcomposite
93 ];
94
95 dontWrapQtApps = true;
96
97 pluginsSubdir = "lib/qt-${qtbase.qtCompatVersion}/plugins";
98
99 installPhase = ''
100 mkdir -p $out $(dirname ${pluginsSubdir}/geoservices)
101 mkdir -p ${pluginsSubdir}/geoservices
102 mv *.so ${pluginsSubdir}/geoservices
103 mv lib $out/
104 '';
105
106 meta = with lib; {
107 inherit (src.meta) homepage;
108 description = "QtLocation plugin for Google maps tile API";
109 maintainers = with maintainers; [ orivej ];
110 license = licenses.mit;
111 platforms = platforms.all;
112 };
113 };
114
115 get-version = writeShellScriptBin "get-version" ''
116 echo -n ${version}
117 '';
118
119in
120stdenv.mkDerivation {
121 pname = "subsurface";
122 inherit version;
123
124 src = subsurfaceSrc;
125
126 postPatch = ''
127 install -m555 -t scripts ${lib.getExe get-version}
128 '';
129
130 buildInputs = [
131 bluez
132 curl
133 googlemaps
134 grantlee
135 libdc
136 libgit2
137 libssh2
138 libxml2
139 libxslt
140 libzip
141 qtbase
142 qtconnectivity
143 qtsvg
144 qttools
145 qtwebengine
146 ];
147
148 nativeBuildInputs = [
149 cmake
150 wrapQtAppsHook
151 pkg-config
152 ];
153
154 cmakeFlags = [
155 "-DLIBDC_FROM_PKGCONFIG=ON"
156 "-DNO_PRINTING=OFF"
157 ];
158
159 passthru = {
160 inherit version libdc googlemaps;
161 updateScript = writeScript "update-subsurface" ''
162 #!/usr/bin/env nix-shell
163 #!nix-shell -i bash -p git common-updater-scripts
164
165 set -eu -o pipefail
166 tmpdir=$(mktemp -d)
167 pushd $tmpdir
168 git clone -b current https://github.com/subsurface/subsurface.git
169 cd subsurface
170 # this returns 6.0.????-local
171 new_version=$(./scripts/get-version.sh | cut -d '-' -f 1)
172 new_rev=$(git rev-list -1 HEAD)
173 popd
174 update-source-version subsurface "$new_version" --rev="$new_rev"
175 rm -rf $tmpdir
176 '';
177 };
178
179 meta = with lib; {
180 description = "Divelog program";
181 mainProgram = "subsurface";
182 longDescription = ''
183 Subsurface can track single- and multi-tank dives using air, Nitrox or TriMix.
184 It allows tracking of dive locations including GPS coordinates (which can also
185 conveniently be entered using a map interface), logging of equipment used and
186 names of other divers, and lets users rate dives and provide additional notes.
187 '';
188 homepage = "https://subsurface-divelog.org";
189 license = licenses.gpl2;
190 maintainers = with maintainers; [ mguentner ];
191 platforms = platforms.all;
192 };
193}