Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
qgis-next: add qgis 3.38.0 as next version
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed Jun 25, 2024
1 parent 7c962b9 commit cfc5c58
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 0 deletions.
12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@

qgis-ltr = pkgs.callPackage ./pkgs/qgis/ltr.nix { qgis-ltr-unwrapped = qgis-ltr-unwrapped; };

# QGIS-NEXT
qgis-next-unwrapped = pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped-3_38.nix {
inherit geos gdal libspatialindex libspatialite pdal proj;

python3 = qgis-python;
withGrass = false;
};

qgis-next = pkgs.callPackage ./pkgs/qgis/3_38.nix { qgis-unwrapped = qgis-next-unwrapped; };

# QGIS plugins
qgis-plugins =
let
Expand Down Expand Up @@ -313,6 +323,8 @@
qgis-unwrapped
qgis-ltr
qgis-ltr-unwrapped
qgis-next
qgis-next-unwrapped

# Meta packages
all-packages
Expand Down
43 changes: 43 additions & 0 deletions pkgs/qgis/3_38.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ lib
, makeWrapper
, nixosTests
, symlinkJoin

, extraPythonPackages ? (ps: [ ])
, qgis-unwrapped

, libsForQt5
}:

symlinkJoin rec {

inherit (qgis-unwrapped) version;
name = "qgis-${version}";

paths = [ qgis-unwrapped ];

nativeBuildInputs = [
makeWrapper
qgis-unwrapped.py.pkgs.wrapPython
];

# extend to add to the python environment of QGIS without rebuilding QGIS application.
pythonInputs = qgis-unwrapped.pythonBuildInputs ++ (extraPythonPackages qgis-unwrapped.py.pkgs);

postBuild = ''
# unpackPhase
buildPythonPath "$pythonInputs"
wrapProgram $out/bin/qgis \
--prefix PATH : $program_PATH \
--set PYTHONPATH $program_PYTHONPATH
'';

passthru = {
unwrapped = qgis-unwrapped;
tests.qgis = nixosTests.qgis;
};

meta = qgis-unwrapped.meta;
}
49 changes: 49 additions & 0 deletions pkgs/qgis/set-pyqt-package-dirs-3_38.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/cmake/FindPyQt5.cmake b/cmake/FindPyQt5.cmake
index b51fd0075e..87ee317e05 100644
--- a/cmake/FindPyQt5.cmake
+++ b/cmake/FindPyQt5.cmake
@@ -25,7 +25,7 @@ ELSE(EXISTS PYQT5_VERSION_STR)
IF(SIP_BUILD_EXECUTABLE)
# SIP >= 5.0 path

- FILE(GLOB _pyqt5_metadata "${Python_SITEARCH}/PyQt5-*.dist-info/METADATA")
+ FILE(GLOB _pyqt5_metadata "@pyQt5PackageDir@/PyQt5-*.dist-info/METADATA")
IF(_pyqt5_metadata)
FILE(READ ${_pyqt5_metadata} _pyqt5_metadata_contents)
STRING(REGEX REPLACE ".*\nVersion: ([^\n]+).*$" "\\1" PYQT5_VERSION_STR ${_pyqt5_metadata_contents})

diff --git a/cmake/FindQsci.cmake b/cmake/FindQsci.cmake
index 69e41c1fe9..5456c3d59b 100644
--- a/cmake/FindQsci.cmake
+++ b/cmake/FindQsci.cmake
@@ -24,7 +24,7 @@ ELSE(QSCI_MOD_VERSION_STR)
IF(SIP_BUILD_EXECUTABLE)
# SIP >= 5.0 path

- FILE(GLOB _qsci_metadata "${Python_SITEARCH}/QScintilla*.dist-info/METADATA")
+ FILE(GLOB _qsci_metadata "@qsciPackageDir@/QScintilla*.dist-info/METADATA")
IF(_qsci_metadata)
FILE(READ ${_qsci_metadata} _qsci_metadata_contents)
STRING(REGEX REPLACE ".*\nVersion: ([^\n]+).*$" "\\1" QSCI_MOD_VERSION_STR ${_qsci_metadata_contents})
@@ -33,7 +33,7 @@ ELSE(QSCI_MOD_VERSION_STR)
ENDIF(_qsci_metadata)

IF(QSCI_MOD_VERSION_STR)
- SET(QSCI_SIP_DIR "${PYQT_SIP_DIR}")
+ SET(QSCI_SIP_DIR "@qsciPackageDir@/PyQt5/bindings")
SET(QSCI_FOUND TRUE)
ENDIF(QSCI_MOD_VERSION_STR)

diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 4cd19c3af4..668cc6a5e6 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -212,7 +212,7 @@ if (WITH_GUI)
install(FILES ${QGIS_PYTHON_OUTPUT_DIRECTORY}/_gui.pyi DESTINATION ${QGIS_PYTHON_DIR})
endif()
if(QSCI_SIP_DIR)
- set(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -I ${QSCI_SIP_DIR})
+ set(SIP_BUILD_EXTRA_OPTIONS ${SIP_BUILD_EXTRA_OPTIONS} --include-dir=${QSCI_SIP_DIR})
else()
message(STATUS "Qsci sip file not found - disabling bindings for derived classes")
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QSCI_SIP)
184 changes: 184 additions & 0 deletions pkgs/qgis/unwrapped-3_38.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{ lib
, fetchFromGitHub
, makeWrapper
, mkDerivation
, substituteAll
, wrapGAppsHook
, wrapQtAppsHook

, withGrass ? true
, withWebKit ? false

, bison
, cmake
, draco
, exiv2
, fcgi
, flex
, geos
, gdal
, grass
, gsl
, hdf5
, libspatialindex
, libspatialite
, libzip
, netcdf
, ninja
, openssl
, pdal
, postgresql
, proj
, protobuf
, python3
, qca-qt5
, qscintilla
, qt3d
, qtbase
, qtkeychain
, qtlocation
, qtmultimedia
, qtsensors
, qtserialport
, qtwebkit
, qtxmlpatterns
, qwt
, sqlite
, txt2tags
, zstd
}:

let
# pyqt5 override was moved to flake.nix
py = python3;

pythonBuildInputs = with py.pkgs; [
chardet
gdal
jinja2
numpy
owslib
psycopg2
pygments
pyqt5
pyqt-builder
python-dateutil
pytz
pyyaml
qscintilla-qt5
requests
setuptools
sip
six
urllib3
];
in mkDerivation rec {
version = "3.38.0";
pname = "qgis-unwrapped";

src = fetchFromGitHub {
owner = "qgis";
repo = "QGIS";
rev = "final-${lib.replaceStrings [ "." ] [ "_" ] version}";
hash = "sha256-vL9Go8Kn6VFOeztD/LZi5QHpZVPFfOFarTsCLTf4D2s=";
};

passthru = {
inherit pythonBuildInputs;
inherit py;
};

nativeBuildInputs = [
makeWrapper
wrapGAppsHook
wrapQtAppsHook

bison
cmake
flex
ninja
];

buildInputs = [
draco
exiv2
fcgi
geos
gsl
hdf5
libspatialindex
libspatialite
libzip
netcdf
openssl
pdal
postgresql
proj
protobuf
qca-qt5
qscintilla
qt3d
qtbase
qtkeychain
qtlocation
qtmultimedia
qtsensors
qtserialport
qtxmlpatterns
qwt
sqlite
txt2tags
zstd
] ++ lib.optional withGrass grass
++ lib.optional withWebKit qtwebkit
++ pythonBuildInputs;

patches = [
(substituteAll {
src = ./set-pyqt-package-dirs-3_38.patch;
pyQt5PackageDir = "${py.pkgs.pyqt5}/${py.pkgs.python.sitePackages}";
qsciPackageDir = "${py.pkgs.qscintilla-qt5}/${py.pkgs.python.sitePackages}";
})
];

# Add path to Qt platform plugins
# (offscreen is needed by "${APIS_SRC_DIR}/generate_console_pap.py")
env.QT_QPA_PLATFORM_PLUGIN_PATH="${qtbase}/${qtbase.qtPluginPrefix}/platforms";

cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DWITH_3D=True"
"-DWITH_PDAL=True"
"-DENABLE_TESTS=False"
"-DQT_PLUGINS_DIR=${qtbase}/${qtbase.qtPluginPrefix}"
] ++ lib.optional (!withWebKit) "-DWITH_QTWEBKIT=OFF"
++ lib.optional withGrass (let
gmajor = lib.versions.major grass.version;
gminor = lib.versions.minor grass.version;
in "-DGRASS_PREFIX${gmajor}=${grass}/grass${gmajor}${gminor}"
);

qtWrapperArgs = [
"--set QT_QPA_PLATFORM_PLUGIN_PATH ${qtbase}/${qtbase.qtPluginPrefix}/platforms"
];

dontWrapGApps = true; # wrapper params passed below

postFixup = lib.optionalString withGrass ''
# GRASS has to be availble on the command line even though we baked in
# the path at build time using GRASS_PREFIX.
# Using wrapGAppsHook also prevents file dialogs from crashing the program
# on non-NixOS.
wrapProgram $out/bin/qgis \
"''${gappsWrapperArgs[@]}" \
--prefix PATH : ${lib.makeBinPath [ grass ]}
'';

meta = with lib; {
description = "Free and Open Source Geographic Information System";
homepage = "https://www.qgis.org";
license = licenses.gpl2Plus;
maintainers = with maintainers; teams.geospatial.members ++ [ lsix ];
platforms = with platforms; linux;
};
}

0 comments on commit cfc5c58

Please sign in to comment.