nixpkgs/nixos/tests/qgis.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.6 KiB
Nix
Raw Normal View History

2024-09-16 10:51:21 +00:00
import ./make-test-python.nix ({ pkgs, lib, package, ... }:
let
2024-09-16 10:51:21 +00:00
qgisPackage = package.override { withServer = true; };
testScript = pkgs.writeTextFile {
name = "qgis-test.py";
text = (builtins.readFile ../../pkgs/applications/gis/qgis/test.py);
};
in
{
name = "qgis";
meta = {
maintainers = with lib; [ teams.geospatial.members ];
};
nodes = {
2024-09-16 10:51:21 +00:00
machine = { config, pkgs, ... }:
let
qgisServerUser = config.services.nginx.user;
qgisServerSocket = "/run/qgis_mapserv.socket";
in
{
virtualisation.diskSize = 2 * 1024;
imports = [ ./common/x11.nix ];
2024-09-16 10:51:21 +00:00
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" ];
};
2024-09-16 10:51:21 +00:00
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()
2024-09-16 10:51:21 +00:00
# test desktop
machine.succeed("${qgisPackage}/bin/qgis --version | grep 'QGIS ${qgisPackage.version}'")
machine.succeed("${qgisPackage}/bin/qgis --code ${testScript}")
2024-09-16 10:51:21 +00:00
# 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'")
'';
})