Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ in {
qemu-vm-volatile-root = runTest ./qemu-vm-volatile-root.nix;
qemu-vm-external-disk-image = runTest ./qemu-vm-external-disk-image.nix;
qemu-vm-store = runTest ./qemu-vm-store.nix;
qgis = handleTest ./qgis.nix { qgisPackage = pkgs.qgis; };
qgis-ltr = handleTest ./qgis.nix { qgisPackage = pkgs.qgis-ltr; };
qgis = handleTest ./qgis.nix { package = pkgs.qgis; };
qgis-ltr = handleTest ./qgis.nix { package = pkgs.qgis-ltr; };
qownnotes = handleTest ./qownnotes.nix {};
qtile = handleTestOn ["x86_64-linux" "aarch64-linux"] ./qtile/default.nix {};
quake3 = handleTest ./quake3.nix {};
Expand Down
62 changes: 59 additions & 3 deletions nixos/tests/qgis.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ./make-test-python.nix ({ pkgs, lib, qgisPackage, ... }:
import ./make-test-python.nix ({ pkgs, lib, package, ... }:
let
qgisPackage = package.override { withServer = true; };
testScript = pkgs.writeTextFile {
name = "qgis-test.py";
text = (builtins.readFile ../../pkgs/applications/gis/qgis/test.py);
Expand All @@ -12,19 +13,74 @@ import ./make-test-python.nix ({ pkgs, lib, qgisPackage, ... }:
};

nodes = {
machine = { pkgs, ... }: {
machine = { config, pkgs, ... }:

let
qgisServerUser = config.services.nginx.user;
qgisServerSocket = "/run/qgis_mapserv.socket";
in
{
virtualisation.diskSize = 2 * 1024;

imports = [ ./common/x11.nix ];
environment.systemPackages = [ qgisPackage ];
environment.systemPackages = [
qgisPackage
];

systemd.sockets.qgis-server = {
listenStreams = [ qgisServerSocket ];
socketConfig = {
Accept = false;
SocketUser = qgisServerUser;
SocketMode = 0600;
};
wantedBy = ["sockets.target" "qgis-server.service"];
before = [ "qgis-server.service" ];
};

systemd.services.qgis-server = {
description = "QGIS server";
serviceConfig = {
User = qgisServerUser;
StandardOutput = "null";
StandardError = "journal";
StandardInput = "socket";
Environment = [
"QT_QPA_PLATFORM_PLUGIN_PATH=${pkgs.libsForQt5.qt5.qtbase}/${pkgs.libsForQt5.qt5.qtbase.qtPluginPrefix}/platforms"
"QGIS_SERVER_LOG_LEVEL=0"
"QGIS_SERVER_LOG_STDERR=1"
];
ExecStart = "${qgisPackage}/lib/cgi-bin/qgis_mapserv.fcgi";
};
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
};

services.nginx = {
enable = true;
virtualHosts."qgis" = {
locations."~".extraConfig = ''
gzip off;
include ${pkgs.nginx}/conf/fastcgi_params;
include ${pkgs.nginx}/conf/fastcgi.conf;
fastcgi_pass unix:${qgisServerSocket};
'';
};
};
};
};

testScript = ''
start_all()

# test desktop
machine.succeed("${qgisPackage}/bin/qgis --version | grep 'QGIS ${qgisPackage.version}'")
machine.succeed("${qgisPackage}/bin/qgis --code ${testScript}")

# test server
machine.succeed("${qgisPackage}/bin/qgis_mapserver --version | grep 'QGIS ${qgisPackage.version}'")

machine.succeed("curl --head http://localhost | grep 'Server:.*${qgisPackage.version}'")
machine.succeed("curl http://localhost/index.json | grep 'Landing page as JSON'")
'';
})
2 changes: 2 additions & 0 deletions pkgs/applications/gis/qgis/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

# unwrapped package parameters
, withGrass ? false
, withServer ? false
, withWebKit ? false
}:
let
qgis-unwrapped = libsForQt5.callPackage ./unwrapped.nix {
withGrass = withGrass;
withServer = withServer;
withWebKit = withWebKit;
};
in symlinkJoin rec {
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/gis/qgis/ltr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

# unwrapped package parameters
, withGrass ? false
, withServer ? false
, withWebKit ? false
}:
let
qgis-ltr-unwrapped = libsForQt5.callPackage ./unwrapped-ltr.nix {
withGrass = withGrass;
withServer = withServer;
withWebKit = withWebKit;
};
in symlinkJoin rec {
Expand Down
6 changes: 5 additions & 1 deletion pkgs/applications/gis/qgis/unwrapped-ltr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, wrapQtAppsHook

, withGrass
, withServer
, withWebKit

, bison
Expand Down Expand Up @@ -155,7 +156,10 @@ in mkDerivation rec {
"-DWITH_PDAL=True"
"-DENABLE_TESTS=False"
] ++ lib.optional (!withWebKit) "-DWITH_QTWEBKIT=OFF"
++ lib.optional withGrass (let
++ lib.optional withServer [
"-DWITH_SERVER=True"
"-DQGIS_CGIBIN_SUBDIR=${placeholder "out"}/lib/cgi-bin"
] ++ lib.optional withGrass (let
gmajor = lib.versions.major grass.version;
gminor = lib.versions.minor grass.version;
in "-DGRASS_PREFIX${gmajor}=${grass}/grass${gmajor}${gminor}"
Expand Down
6 changes: 5 additions & 1 deletion pkgs/applications/gis/qgis/unwrapped.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, wrapQtAppsHook

, withGrass
, withServer
, withWebKit

, bison
Expand Down Expand Up @@ -157,7 +158,10 @@ in mkDerivation rec {
"-DENABLE_TESTS=False"
"-DQT_PLUGINS_DIR=${qtbase}/${qtbase.qtPluginPrefix}"
] ++ lib.optional (!withWebKit) "-DWITH_QTWEBKIT=OFF"
++ lib.optional withGrass (let
++ lib.optional withServer [
"-DWITH_SERVER=True"
"-DQGIS_CGIBIN_SUBDIR=${placeholder "out"}/lib/cgi-bin"
Copy link
Contributor

Choose a reason for hiding this comment

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

For my culture, why do we need placeholder "out here? $out directly doesn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if I remember correctly, but I guess just using $out didn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Why not $(out)?

] ++ lib.optional withGrass (let
gmajor = lib.versions.major grass.version;
gminor = lib.versions.minor grass.version;
in "-DGRASS_PREFIX${gmajor}=${grass}/grass${gmajor}${gminor}"
Expand Down