Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build QGIS and dependencies on darwin #36902

Merged
merged 10 commits into from
Mar 21, 2018
4 changes: 4 additions & 0 deletions pkgs/applications/gis/grass/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ stdenv.mkDerivation {
readline ffmpeg makeWrapper wxGTK30 netcdf geos postgresql mysql.connector-c blas ]
++ (with python2Packages; [ python dateutil wxPython30 numpy ]);

# On Darwin the installer tries to symlink the help files into a system
# directory
patches = [ ./no_symbolic_links.patch ];

configureFlags = [
"--with-proj-share=${proj}/share/proj"
"--without-opengl"
Expand Down
37 changes: 37 additions & 0 deletions pkgs/applications/gis/grass/no_symbolic_links.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/include/Make/Install.make b/include/Make/Install.make
index 0aba138..8ba74bc 100644
--- a/include/Make/Install.make
+++ b/include/Make/Install.make
@@ -116,11 +116,6 @@ real-install: | $(INST_DIR) $(UNIX_BIN)
-$(INSTALL) config.status $(INST_DIR)/config.status
-$(CHMOD) -R a+rX $(INST_DIR) 2>/dev/null

-ifneq ($(findstring darwin,$(ARCH)),)
- @# enable OSX Help Viewer
- @/bin/ln -sfh "$(INST_DIR)/docs/html" /Library/Documentation/Help/GRASS-$(GRASS_VERSION_MAJOR).$(GRASS_VERSION_MINOR)
-endif
-
$(INST_DIR) $(UNIX_BIN):
$(MAKE_DIR_CMD) $@

diff --git a/macosx/app/build_html_user_index.sh b/macosx/app/build_html_user_index.sh
index 04e63eb..c9d9c2c 100755
--- a/macosx/app/build_html_user_index.sh
+++ b/macosx/app/build_html_user_index.sh
@@ -140,7 +140,6 @@ else
# echo "<tr><td valign=\"top\"><a href=\"$HTMLDIRG/$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
# make them local to user to simplify page links
echo "<tr><td valign=\"top\"><a href=\"global_$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
- ln -sf "$HTMLDIRG/$i" global_$i
done
done
fi
@@ -183,8 +182,3 @@ echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
</html>" > $i.html
done

-# add Help Viewer links in user docs folder
-
-mkdir -p $HOME/Library/Documentation/Help/
-ln -sfh ../../GRASS/$GRASS_MMVER/Modules/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER-addon
-ln -sfh $GISBASE/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER
55 changes: 44 additions & 11 deletions pkgs/applications/gis/qgis/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
{ stdenv, fetchurl, fetchpatch, gdal, cmake, qt4, flex, bison, proj, geos, xlibsWrapper, sqlite, gsl
, qwt, fcgi, python2Packages, libspatialindex, libspatialite, qscintilla, postgresql, makeWrapper
, qjson, qca2, txt2tags, openssl
, withGrass ? false, grass
, qjson, qca2, txt2tags, openssl, darwin, pkgconfig
, withGrass ? false, grass, IOKit, ApplicationServices
}:

stdenv.mkDerivation rec {
name = "qgis-2.18.16";

buildInputs = [ gdal qt4 flex openssl bison proj geos xlibsWrapper sqlite gsl qwt qscintilla
fcgi libspatialindex libspatialite postgresql qjson qca2 txt2tags ] ++
fcgi libspatialindex libspatialite postgresql qjson qca2 txt2tags pkgconfig ]
++
(stdenv.lib.optionals stdenv.isDarwin [IOKit ApplicationServices])
++
(stdenv.lib.optional withGrass grass) ++
(stdenv.lib.optional (stdenv.isDarwin && withGrass) darwin.apple_sdk.libs.utmp) ++
(with python2Packages; [ jinja2 numpy psycopg2 pygments requests python2Packages.qscintilla sip ]);

nativeBuildInputs = [ cmake makeWrapper ];
nativeBuildInputs = [ cmake makeWrapper pkgconfig ];

# `make -f src/providers/wms/CMakeFiles/wmsprovider_a.dir/build.make src/providers/wms/CMakeFiles/wmsprovider_a.dir/qgswmssourceselect.cpp.o`:
# fatal error: ui_qgsdelimitedtextsourceselectbase.h: No such file or directory
enableParallelBuilding = false;

preConfigure = ''
NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config --cflags libspatialindex)"
'';

# To handle the lack of 'local' RPATH; required, as they call one of
# their built binaries requiring their libs, in the build process.
preBuild = ''
Expand All @@ -29,19 +37,44 @@ stdenv.mkDerivation rec {
sha256 = "0d880m013kzi4qiyr27yjx6hzpb652slp66gyqgw9ziw03wy12c9";
};

cmakeFlags = stdenv.lib.optional withGrass "-DGRASS_PREFIX7=${grass}/${grass.name}";
# CMAKE_FIND_FRAMEWORK=never stops the installer choosing system
# installed frameworks
# QGIS_MACAPP_BUNDLE=0 stops the installer copying the Qt binaries into the
# installation which causes havoc
# Building RelWithDebInfo allows QGIS_DEBUG to print debugging information
cmakeFlags = stdenv.lib.optional withGrass "-DGRASS_PREFIX7=${grass}/${grass.name}"
++ stdenv.lib.optional stdenv.isDarwin
(["-DCMAKE_FIND_FRAMEWORK=never"]
++ ["-DQGIS_MACAPP_BUNDLE=0"]);
# ++ ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this left in intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unsure whether to leave it in or not as it's very useful to see the terminal output when running the application. Like I said, the derivation is currently not perfect but much better than what is currently in the repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release type affects the terminal output? 🤦‍♂️ ah well, maybe add a comment clarifying how it's useful then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's a graphical application. Building with debug info makes the terminal output very verbose as you use the gui.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the actual thing that debug info refers to is the debugging symbols that map the machine code sections back to source code. Terminal output should not usually be affected, but it's up to the application developer whether that's actually the case.


postInstall = ''
wrapProgram $out/bin/qgis \
--prefix PYTHONPATH : $PYTHONPATH \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ openssl ]}
'';


postInstall =
(stdenv.lib.optionalString stdenv.isLinux ''
wrapProgram $out/bin/qgis \
--set PYTHONPATH $PYTHONPATH \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ openssl ]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it already existed, this is really ugly. We should aim at patching references over using LD_LIBRARY_PATH

'') +
(stdenv.lib.optionalString stdenv.isDarwin ''
# Necessary for QGIS to find the correct default GRASS path
${stdenv.lib.optionalString withGrass "ln -sf ${grass} $out/QGIS.app/Contents/MacOS/grass"}
for file in $(find $out -type f -name "QGIS"); do
wrapProgram "$file" \
--prefix DYLD_LIBRARY_PATH : "${qwt}/lib" \
--prefix DYLD_LIBRARY_PATH : "${qscintilla}/lib" \
${stdenv.lib.optionalString withGrass "--prefix PATH : ${grass}/bin"} \
--set PYTHONPATH $PYTHONPATH
done
mkdir -p $out/bin
ln -s $out/QGIS.app/Contents/MacOS/QGIS $out/bin/qgis
'');

meta = {
description = "User friendly Open Source Geographic Information System";
homepage = http://www.qgis.org;
license = stdenv.lib.licenses.gpl2Plus;
platforms = with stdenv.lib.platforms; linux;
platforms = with stdenv.lib.platforms; unix;
maintainers = with stdenv.lib.maintainers; [viric];
};
}
2 changes: 1 addition & 1 deletion pkgs/development/libraries/libspatialindex/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ stdenv.mkDerivation rec {
description = "Extensible spatial index library in C++";
homepage = http://libspatialindex.github.io/;
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.linux;
platforms = stdenv.lib.platforms.unix;
};
}
6 changes: 3 additions & 3 deletions pkgs/development/libraries/qca2/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, cmake, pkgconfig, qt }:
{ stdenv, fetchurl, cmake, pkgconfig, qt, darwin }:

stdenv.mkDerivation rec {
name = "qca-${version}";
Expand All @@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
};

nativeBuildInputs = [ cmake pkgconfig ];
buildInputs = [ qt ];
buildInputs = [ (stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security) qt ];

enableParallelBuilding = true;

Expand All @@ -25,6 +25,6 @@ stdenv.mkDerivation rec {
license = "LGPL";
homepage = http://delta.affinix.com/qca;
maintainers = [ maintainers.sander ];
platforms = platforms.linux;
platforms = platforms.unix;
};
}
8 changes: 8 additions & 0 deletions pkgs/development/libraries/qscintilla/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
, withQt5 ? false, qtbase ? null, qtmacextras ? null, qmake ? null
}:

# Fix Xcode 8 compilation problem
let xcodePatch =
fetchurl { url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a651d71/qscintilla2/xcode-8.patch";
sha256 = "1a88309fdfd421f4458550b710a562c622d72d6e6fdd697107e4a43161d69bc9"; };
in
stdenv.mkDerivation rec {
pname = "qscintilla";
version = "2.9.4";
Expand All @@ -19,6 +24,9 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ unzip ]
++ (if withQt5 then [ qmake ] else [ qmake4Hook ]);


patches = [] ++ lib.optional withQt5 [ xcodePatch ];

enableParallelBuilding = true;

preConfigure = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/qwt/6.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
homepage = http://qwt.sourceforge.net/;
# LGPL 2.1 plus a few exceptions (more liberal)
license = stdenv.lib.licenses.qwt;
platforms = platforms.linux;
platforms = platforms.unix;
maintainers = [ maintainers.bjornfor ];
branch = "6";
};
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/qwt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
homepage = http://qwt.sourceforge.net/;
# LGPL 2.1 plus a few exceptions (more liberal)
license = stdenv.lib.licenses.qwt;
platforms = platforms.linux;
platforms = platforms.unix;
maintainers = [ maintainers.bjornfor ];
};
}
4 changes: 3 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17225,7 +17225,9 @@ with pkgs;

qemu-riscv = callPackage ../applications/virtualization/qemu/riscv.nix {};

qgis = callPackage ../applications/gis/qgis {};
qgis = callPackage ../applications/gis/qgis {
inherit (darwin.apple_sdk.frameworks) IOKit ApplicationServices;
};

qgroundcontrol = libsForQt5.callPackage ../applications/science/robotics/qgroundcontrol { };

Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14189,7 +14189,7 @@ in {
description = "A Python binding to QScintilla, Qt based text editing control";
license = licenses.lgpl21Plus;
maintainers = with maintainers; [ danbst ];
platforms = platforms.linux;
platforms = platforms.unix;
};
});

Expand Down