1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 gitUpdater,
6 testers,
7 libiodata,
8 pkg-config,
9 qmake,
10 qtbase,
11 sailfish-access-control,
12 tzdata,
13 wrapQtAppsHook,
14}:
15
16stdenv.mkDerivation (finalAttrs: {
17 pname = "timed";
18 version = "3.6.24";
19
20 outputs = [
21 "out"
22 "lib"
23 "dev"
24 ];
25
26 src = fetchFromGitHub {
27 owner = "sailfishos";
28 repo = "timed";
29 tag = finalAttrs.version;
30 hash = "sha256-6axLd3XRCIsuYnKQ0AiCD6Cxut9Ck9hNWwIbkj4Aza8=";
31 };
32
33 postPatch = ''
34 substituteInPlace src/{lib/lib,voland/voland}.pro \
35 --replace-fail '$$[QT_INSTALL_LIBS]' "$lib/lib" \
36 --replace-fail '/usr/include' "$dev/include" \
37 --replace-fail '$$[QT_INSTALL_DATA]' "$dev"
38
39 substituteInPlace src/server/server.pro \
40 --replace-fail '/usr/bin' "$out/bin" \
41 --replace-fail '/etc' "$out/etc" \
42 --replace-fail '/usr/lib' "$out/lib"
43
44 substituteInPlace tests/tests.pro \
45 --replace-fail '/opt' "$dev/opt" \
46
47 substituteInPlace tests/ut_networktime/ut_networktime.pro \
48 --replace-fail '/opt' "$dev/opt" \
49 --replace-fail '/etc' "$dev/etc"
50
51 substituteInPlace tests/tst_events/tst_events.pro \
52 --replace-fail '/opt' "$dev/opt"
53
54 substituteInPlace tools/timedclient/timedclient.pro \
55 --replace-fail '/usr/bin' "$out/bin"
56
57 substituteInPlace \
58 src/lib/aliases.cpp \
59 src/server/settings.cpp \
60 --replace-fail '/usr/share/zoneinfo' '${tzdata}/share/zoneinfo'
61 '';
62
63 # QMake doesn't handle this well
64 strictDeps = false;
65
66 nativeBuildInputs = [
67 pkg-config
68 qmake
69 wrapQtAppsHook
70 ];
71
72 buildInputs = [
73 libiodata
74 sailfish-access-control
75 ];
76
77 # Do all configuring now, not during build
78 postConfigure = ''
79 make qmake_all
80 '';
81
82 env = {
83 TIMED_VERSION = "${finalAttrs.version}";
84
85 # Other subprojects expect library to already be present
86 NIX_CFLAGS_COMPILE = "-isystem ${placeholder "dev"}/include";
87 NIX_LDFLAGS = "-L${placeholder "out"}/lib";
88 };
89
90 preBuild = ''
91 pushd src/lib
92 make ''${enableParallelBuilding:+-j$NIX_BUILD_CORES}
93 make install
94 popd
95 '';
96
97 passthru = {
98 updateScript = gitUpdater { };
99 tests.pkg-config = testers.hasPkgConfigModules {
100 package = finalAttrs.finalPackage;
101 # Version fields exclude patch-level
102 };
103 };
104
105 meta = {
106 description = "Time daemon managing system time, time zone and settings";
107 homepage = "https://github.com/sailfishos/timed";
108 changelog = "https://github.com/sailfishos/timed/releases/tag/${finalAttrs.version}";
109 license = lib.licenses.lgpl21Only;
110 mainProgram = "timed";
111 teams = [ lib.teams.lomiri ];
112 platforms = lib.platforms.linux;
113 pkgConfigModules = [
114 "timed-qt${lib.versions.major qtbase.version}"
115 "timed-voland-qt${lib.versions.major qtbase.version}"
116 ];
117 };
118})