1{
2 lib,
3 stdenv,
4 buildPackages,
5 mkDerivation,
6 apple-sdk_14,
7 perl,
8 qmake,
9 patches,
10 srcs,
11 pkgsHostTarget,
12}:
13
14let
15 inherit (lib) licenses maintainers platforms;
16in
17
18args:
19
20let
21 inherit (args) pname;
22 version = args.version or srcs.${pname}.version;
23 src = args.src or srcs.${pname}.src;
24in
25
26mkDerivation (
27 args
28 // {
29 inherit pname version src;
30 patches = (args.patches or [ ]) ++ (patches.${pname} or [ ]);
31
32 buildInputs =
33 args.buildInputs or [ ]
34 # Per https://doc.qt.io/qt-5/macos.html#supported-versions
35 ++ lib.optionals stdenv.hostPlatform.isDarwin [
36 apple-sdk_14
37 ];
38
39 nativeBuildInputs =
40 (args.nativeBuildInputs or [ ])
41 ++ [
42 perl
43 qmake
44 ]
45 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
46 pkgsHostTarget.qt5.qtbase.dev
47 ];
48 propagatedBuildInputs =
49 (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or [ ])
50 ++ (args.propagatedBuildInputs or [ ]);
51 }
52 // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
53 depsBuildBuild = [ buildPackages.stdenv.cc ] ++ (args.depsBuildBuild or [ ]);
54 }
55 // {
56
57 outputs =
58 args.outputs or [
59 "out"
60 "dev"
61 ];
62 setOutputFlags = args.setOutputFlags or false;
63
64 preHook = ''
65 . ${./hooks/move-qt-dev-tools.sh}
66 . ${./hooks/fix-qt-builtin-paths.sh}
67 '';
68
69 preConfigure = ''
70 ${args.preConfigure or ""}
71
72 fixQtBuiltinPaths . '*.pr?'
73 ''
74 +
75 lib.optionalString (builtins.compareVersions "5.15.0" version <= 0)
76 # Note: We use ${version%%-*} to remove any tag from the end of the version
77 # string. Version tags are added by Nixpkgs maintainers and not reflected in
78 # the source version.
79 ''
80 if [[ -z "$dontCheckQtModuleVersion" ]] \
81 && grep -q '^MODULE_VERSION' .qmake.conf 2>/dev/null \
82 && ! grep -q -F "''${version%%-*}" .qmake.conf 2>/dev/null
83 then
84 echo >&2 "error: could not find version ''${version%%-*} in .qmake.conf"
85 echo >&2 "hint: check .qmake.conf and update the package version in Nixpkgs"
86 exit 1
87 fi
88
89 if [[ -z "$dontSyncQt" && -f sync.profile ]]; then
90 syncqt.pl -version "''${version%%-*}"
91 fi
92 '';
93
94 dontWrapQtApps = args.dontWrapQtApps or true;
95
96 postFixup = ''
97 if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
98 find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
99 sed -i "$pc" \
100 -e "/^prefix=/ c prefix=''${!outputLib}" \
101 -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}" \
102 -e "/^includedir=/ c includedir=''${!outputDev}/include"
103 done
104 fi
105
106 moveQtDevTools
107
108 ${args.postFixup or ""}
109 '';
110
111 meta = {
112 homepage = "https://www.qt.io";
113 description = "Cross-platform application framework for C++";
114 license = with licenses; [
115 fdl13Plus
116 gpl2Plus
117 lgpl21Plus
118 lgpl3Plus
119 ];
120 maintainers = with maintainers; [
121 qknight
122 ttuegel
123 periklis
124 bkchr
125 ];
126 platforms = platforms.unix;
127 }
128 // (args.meta or { });
129 }
130)