summaryrefslogtreecommitdiffstats
path: root/pkgs/development/libraries/qt-5/qtModule.nix
blob: db3519cdda51821debe462ee8daf6c5cdea38eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
  lib,
  stdenv,
  buildPackages,
  mkDerivation,
  perl,
  qmake,
  patches,
  srcs,
  pkgsHostTarget,
}:

let
  inherit (lib) licenses maintainers platforms;
in

args:

let
  inherit (args) pname;
  version = args.version or srcs.${pname}.version;
  src = args.src or srcs.${pname}.src;
in

mkDerivation (
  args
  // {
    inherit pname version src;
    patches = (args.patches or [ ]) ++ (patches.${pname} or [ ]);

    buildInputs = args.buildInputs or [ ];

    nativeBuildInputs =
      (args.nativeBuildInputs or [ ])
      ++ [
        perl
        qmake
      ]
      ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
        pkgsHostTarget.qt5.qtbase.dev
      ];
    propagatedBuildInputs =
      (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or [ ])
      ++ (args.propagatedBuildInputs or [ ]);
  }
  // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
    depsBuildBuild = [ buildPackages.stdenv.cc ] ++ (args.depsBuildBuild or [ ]);
  }
  // {

    outputs =
      args.outputs or [
        "out"
        "dev"
      ];
    setOutputFlags = args.setOutputFlags or false;

    preHook = ''
      . ${./hooks/move-qt-dev-tools.sh}
      . ${./hooks/fix-qt-builtin-paths.sh}
    '';

    preConfigure = ''
      ${args.preConfigure or ""}

      fixQtBuiltinPaths . '*.pr?'
    ''
    +
      lib.optionalString (builtins.compareVersions "5.15.0" version <= 0)
        # Note: We use ${version%%-*} to remove any tag from the end of the version
        # string. Version tags are added by Nixpkgs maintainers and not reflected in
        # the source version.
        ''
          if [[ -z "$dontCheckQtModuleVersion" ]] \
              && grep -q '^MODULE_VERSION' .qmake.conf 2>/dev/null \
              && ! grep -q -F "''${version%%-*}" .qmake.conf 2>/dev/null
          then
            echo >&2 "error: could not find version ''${version%%-*} in .qmake.conf"
            echo >&2 "hint: check .qmake.conf and update the package version in Nixpkgs"
            exit 1
          fi

          if [[ -z "$dontSyncQt" && -f sync.profile ]]; then
            syncqt.pl -version "''${version%%-*}"
          fi
        '';

    dontWrapQtApps = args.dontWrapQtApps or true;

    postFixup = ''
      if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
          find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
              sed -i "$pc" \
                  -e "/^prefix=/ c prefix=''${!outputLib}" \
                  -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}" \
                  -e "/^includedir=/ c includedir=''${!outputDev}/include"
          done
      fi

      ${lib.optionalString (lib.hasAttr "devTools" args) ''devTools="${lib.concatStringsSep " " args.devTools}"''}
      moveQtDevTools

      ${args.postFixup or ""}
    '';

    __structuredAttrs = true;

    meta = {
      homepage = "https://www.qt.io";
      description = "Cross-platform application framework for C++";
      license = with licenses; [
        fdl13Plus
        gpl2Plus
        lgpl21Plus
        lgpl3Plus
      ];
      maintainers = with maintainers; [
        qknight
        bkchr
      ];
      platforms = platforms.unix;
    }
    // (args.meta or { });
  }
)