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 ''
71 ${args.preConfigure or ""}
72
73 fixQtBuiltinPaths . '*.pr?'
74 ''
75 +
76 lib.optionalString (builtins.compareVersions "5.15.0" version <= 0)
77 # Note: We use ${version%%-*} to remove any tag from the end of the version
78 # string. Version tags are added by Nixpkgs maintainers and not reflected in
79 # the source version.
80 ''
81 if [[ -z "$dontCheckQtModuleVersion" ]] \
82 && grep -q '^MODULE_VERSION' .qmake.conf 2>/dev/null \
83 && ! grep -q -F "''${version%%-*}" .qmake.conf 2>/dev/null
84 then
85 echo >&2 "error: could not find version ''${version%%-*} in .qmake.conf"
86 echo >&2 "hint: check .qmake.conf and update the package version in Nixpkgs"
87 exit 1
88 fi
89
90 if [[ -z "$dontSyncQt" && -f sync.profile ]]; then
91 syncqt.pl -version "''${version%%-*}"
92 fi
93 '';
94
95 dontWrapQtApps = args.dontWrapQtApps or true;
96
97 postFixup = ''
98 if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
99 find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
100 sed -i "$pc" \
101 -e "/^prefix=/ c prefix=''${!outputLib}" \
102 -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}" \
103 -e "/^includedir=/ c includedir=''${!outputDev}/include"
104 done
105 fi
106
107 moveQtDevTools
108
109 ${args.postFixup or ""}
110 '';
111
112 meta = {
113 homepage = "https://www.qt.io";
114 description = "Cross-platform application framework for C++";
115 license = with licenses; [
116 fdl13Plus
117 gpl2Plus
118 lgpl21Plus
119 lgpl3Plus
120 ];
121 maintainers = with maintainers; [
122 qknight
123 ttuegel
124 periklis
125 bkchr
126 ];
127 platforms = platforms.unix;
128 } // (args.meta or { });
129 }
130)