summary refs log tree commit diff
path: root/pkgs/development/tools/qtcreator/default.nix
diff options
context:
space:
mode:
authorAndrew Newman <deadloko@gmail.com>2019-05-07 17:18:21 +0300
committerNikolay Amiantov <ab@fmap.me>2019-06-10 12:35:16 +0300
commit6365fa1eb97f730b587df7e3b72025b5173be219 (patch)
tree51f3ecd94e5c34ea1e7d93bde245903451b5e822 /pkgs/development/tools/qtcreator/default.nix
parenteff932e22b090860613dc68fef6fffeeae041757 (diff)
downloadnixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.tar
nixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.tar.gz
nixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.tar.bz2
nixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.tar.lz
nixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.tar.xz
nixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.tar.zst
nixpkgs-6365fa1eb97f730b587df7e3b72025b5173be219.zip
qtcreator: add clang code model compilation
Clang code model provides user with services: code completion,
syntactic and semantic highlighting, diagnostics, outline of symbols,
tooltips, renaming of local symbols. It's naturally depends on llvm and clang.
To make it work with nixos:
1. Add qt version of clang as build dependency.
2. Added patch for clang libc++ regexp trunk regexp not including path
like "libc++-version".
3. Fixed paths to llvm/clang libraries and includes.
4. Fixed name of clazy clang plugin.
Diffstat (limited to 'pkgs/development/tools/qtcreator/default.nix')
-rw-r--r--pkgs/development/tools/qtcreator/default.nix50
1 files changed, 47 insertions, 3 deletions
diff --git a/pkgs/development/tools/qtcreator/default.nix b/pkgs/development/tools/qtcreator/default.nix
index 3c892592d88..03b758cbdc6 100644
--- a/pkgs/development/tools/qtcreator/default.nix
+++ b/pkgs/development/tools/qtcreator/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, makeWrapper
-, qtbase, qtquickcontrols, qtscript, qtdeclarative, qmake
+{ stdenv, fetchurl, fetchgit, fetchpatch, makeWrapper
+, qtbase, qtquickcontrols, qtscript, qtdeclarative, qmake, llvmPackages_8
 , withDocumentation ? false
 }:
 
@@ -8,6 +8,17 @@ with stdenv.lib;
 let
   baseVersion = "4.9";
   revision = "1";
+
+  # Fetch clang from qt vendor, this contains submodules like this:
+  # clang<-clang-tools-extra<-clazy. 
+  clang_qt_vendor = llvmPackages_8.clang-unwrapped.overrideAttrs (oldAttrs: rec {
+    src = fetchgit {
+      url = "https://code.qt.io/clang/clang.git";
+      rev = "c12b012bb7465299490cf93c2ae90499a5c417d5";
+      sha256 = "0mgmnazgr19hnd03xcrv7d932j6dpz88nhhx008b0lv4bah9mqm0";
+    };
+    unpackPhase = "";
+  });
 in
 
 stdenv.mkDerivation rec {
@@ -19,10 +30,29 @@ stdenv.mkDerivation rec {
     sha256 = "10ddp1365rf0z4bs7yzc9hajisp3j6mzjshyd0vpi4ki126j5f3r";
   };
 
-  buildInputs = [ qtbase qtscript qtquickcontrols qtdeclarative ];
+  buildInputs = [ qtbase qtscript qtquickcontrols qtdeclarative llvmPackages_8.libclang clang_qt_vendor llvmPackages_8.llvm ];
 
   nativeBuildInputs = [ qmake makeWrapper ];
 
+  # 0001-Fix-clang-libcpp-regexp.patch is for fixing regexp that is used to 
+  # find clang libc++ library include paths. By default it's not covering paths
+  # like libc++-version, which is default name for libc++ folder in nixos.
+  patches = [ ./0001-Fix-clang-libcpp-regexp.patch 
+
+    # Fix clazy plugin name. This plugin was renamed with clang8 
+    # release, and patch didn't make it into 4.9.1 release. Should be removed 
+    # on qtcreator update, if this problem is fixed.
+    (fetchpatch {
+      url = "https://code.qt.io/cgit/qt-creator/qt-creator.git/patch/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp?id=53c407bc0c87e0b65b537bf26836ddd8e00ead82";
+      sha256 = "1lanp7jg0x8jffajb852q8p4r34facg41l410xsz6s1k91jskbi9";
+    })
+
+    (fetchpatch {
+      url = "https://code.qt.io/cgit/qt-creator/qt-creator.git/patch/src/plugins/clangtools/clangtidyclazyrunner.cpp?id=53c407bc0c87e0b65b537bf26836ddd8e00ead82";
+      sha256 = "1rl0rc2l297lpfhhawvkkmj77zb081hhp0bbi7nnykf3q9ch0clh";
+    })
+  ]; 
+
   doCheck = true;
 
   enableParallelBuilding = true;
@@ -34,6 +64,20 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     substituteInPlace src/plugins/plugins.pro \
       --replace '$$[QT_INSTALL_QML]/QtQuick/Controls' '${qtquickcontrols}/${qtbase.qtQmlPrefix}/QtQuick/Controls'
+
+    # Fix paths for llvm/clang includes directories.
+    substituteInPlace src/shared/clang/clang_defines.pri \
+      --replace '$$clean_path($${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include)' '${clang_qt_vendor}/lib/clang/8.0.0/include' \
+      --replace '$$clean_path($${LLVM_BINDIR})' '${clang_qt_vendor}/bin'
+
+    # Fix include path to find clang and clang-c include directories.  
+    substituteInPlace src/plugins/clangtools/clangtools.pro \
+      --replace 'INCLUDEPATH += $$LLVM_INCLUDEPATH' 'INCLUDEPATH += $$LLVM_INCLUDEPATH ${clang_qt_vendor}'
+
+    # Fix paths to libclang library.
+    substituteInPlace src/shared/clang/clang_installation.pri \
+      --replace 'LIBCLANG_LIBS = -L$${LLVM_LIBDIR}' 'LIBCLANG_LIBS = -L${llvmPackages_8.libclang}/lib' \
+      --replace 'LIBCLANG_LIBS += $${CLANG_LIB}' 'LIBCLANG_LIBS += -lclang'
   '';
 
   preBuild = optional withDocumentation ''