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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- uses: psf/black@stable
with:
options: "--check --verbose"
version: "23.3.0"
version: "25.1.0"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ reports
ext-libs/
.vscode
.vscode-extensions
.qgis_theme>
.claude
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ repos:
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
language_version: python3.13
exclude: |
(?x)^(ext-libs)$
10 changes: 5 additions & 5 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"general": {
"name" : "CPLUS plugin",
"name" : "CPLUS",
"qgisMinimumVersion": 3.22,
"qgisMaximumVersion": 4.99,
"icon": "icon.svg",
Expand All @@ -13,11 +13,11 @@
"tags": ["cplus", "maps", "raster", "analytics"],
"category": "Plugins",
"hasProcessingProvider": "no",
"about": "Adds functionality to use the CPLUS decision support tool in making informed decisions, from spatial information such as land cover, carbon stocks, and potential for carbon sequestration, CPLUS enables the identification of key areas for intervention and investment.",
"author": "Kartoza",
"about": "CPLUS decision support tool in making informed decisions, from spatial information such as land cover, carbon stocks, and potential for carbon sequestration, CPLUS enables the identification of key areas for intervention and investment.",
"author": "Kartoza with Conservation International",
"email": "info@kartoza.com",
"description": "QGIS plugin for the CPLUS framework",
"version": "1.1.24",
"description": "Climate Positive Land Use Strategy (CPLUS)",
"version": "1.1.26",
"changelog": ""
}
}
104 changes: 5 additions & 99 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

209 changes: 188 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,193 @@
# SPDX-FileCopyrightText: Tim Sutton
# SPDX-License-Identifier: MIT
{
description = "Run QGIS with extra Python packages";

inputs.geospatial.url = "github:imincik/geospatial-nix.repo";
inputs.nixpkgs.follows = "geospatial/nixpkgs";

outputs = { self, geospatial, nixpkgs }: {
packages.x86_64-linux.default =
let
pkgs = import nixpkgs {
system = "x86_64-linux";
};
qgisWithExtras = geospatial.packages.x86_64-linux.qgis.override {
extraPythonPackages = ps: [
ps.pyqtwebengine
ps.jsonschema
description = "NixOS developer environment for QGIS plugins.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs systems;

pkgsFor = system: import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in
{
packages = forAllSystems (system:
let
pkgs = pkgsFor system;
postgresWithPostGIS = pkgs.postgresql.withPackages (ps: [ ps.postgis ]);
in
{
default = postgresWithPostGIS;
postgres = postgresWithPostGIS;
});

apps = forAllSystems (system:
let
pkgs = pkgsFor system;
in
{
black-check = {
type = "app";
program = toString (pkgs.writeShellScript "black-check" ''
#!/usr/bin/env bash
set -e
echo "🔍 Checking Python files with black..."
find . -type f -name "*.py" -not -path "./.venv/*" -not -path "./build/*" -not -path "./.git/*" | xargs black --check --diff
echo "✅ All Python files are formatted correctly!"
'');
};

black-fix = {
type = "app";
program = toString (pkgs.writeShellScript "black-fix" ''
#!/usr/bin/env bash
set -e
echo "🔧 Fixing Python files with black..."
find . -type f -name "*.py" -not -path "./.venv/*" -not -path "./build/*" -not -path "./.git/*" | xargs black
echo "✅ All Python files have been formatted!"
'');
};
});


devShells = forAllSystems (system:
let
pkgs = pkgsFor system;
postgresWithPostGIS = pkgs.postgresql.withPackages (ps: [ ps.postgis ]);
in
{
default = pkgs.mkShell {
packages = [

pkgs.actionlint # for checking gh actions
pkgs.bandit
pkgs.bearer
pkgs.chafa
pkgs.nixfmt-rfc-style
pkgs.codeql
pkgs.ffmpeg
pkgs.gdb
pkgs.git
pkgs.minio-client # for grabbing ookla data
pkgs.glogg
pkgs.glow # terminal markdown viewer
pkgs.gource # Software version control visualization
pkgs.gum # UX for TUIs
pkgs.isort
pkgs.jq
pkgs.luaPackages.luacheck
pkgs.markdownlint-cli
pkgs.nixfmt-rfc-style
pkgs.pre-commit
pkgs.nixfmt-rfc-style
pkgs.pyprof2calltree # needed to covert cprofile call trees into a format kcachegrind can read
pkgs.python313
# Python development essentials
pkgs.pyright
pkgs.rpl
pkgs.shellcheck
pkgs.shfmt
pkgs.stylua
pkgs.yamlfmt
pkgs.yamllint
postgresWithPostGIS
pkgs.nodePackages.cspell
(pkgs.python313.withPackages (ps: [
# Add these for SQL linting/formatting:
ps.black
ps.click # needed by black
ps.debugpy
ps.future
ps.docformatter
ps.flake8
ps.gdal
ps.httpx
ps.jsonschema
ps.mypy
ps.numpy
ps.odfpy
ps.pandas
ps.paver
ps.pip
ps.psutil
ps.plotly
];
};
in qgisWithExtras;
};
ps.pytest
ps.rich
ps.setuptools
ps.snakeviz # For visualising cprofiler outputs
ps.sqlfmt
ps.toml
ps.typer
ps.wheel
# For autocompletion in vscode

# This executes some shell code to initialize a venv in $venvDir before
# dropping into the shell
ps.venvShellHook
ps.virtualenv
]))

];
shellHook = ''
unset SOURCE_DATE_EPOCH

# Create a virtual environment in .venv if it doesn't exist
if [ ! -d ".venv" ]; then
python -m venv .venv
fi

# Activate the virtual environment
source .venv/bin/activate

# Upgrade pip and install packages from requirements.txt if it exists
pip install --upgrade pip > /dev/null
if [ -f requirements.txt ]; then
echo "Installing Python requirements from requirements.txt..."
pip install -r requirements.txt > .pip-install.log 2>&1
if [ $? -ne 0 ]; then
echo "❌ Pip install failed. See .pip-install.log for details."
fi
else
echo "No requirements.txt found, skipping pip install."
fi
if [ -f requirements-dev.txt ]; then
echo "Installing Python requirements from requirements-dev.txt..."
pip install -r requirements-dev.txt > .pip-install.log 2>&1
if [ $? -ne 0 ]; then
echo "❌ Pip install failed. See .pip-install.log for details."
fi
else
echo "No requirements-dev.txt found, skipping pip install."
fi

echo "Setting up and running pre-commit hooks..."
echo "-------------------------------------"
pre-commit clean > /dev/null
pre-commit install --install-hooks > /dev/null
pre-commit run --all-files || true

# Colors and styling
CYAN='\033[38;2;83;161;203m'
GREEN='\033[92m'
RED='\033[91m'
RESET='\033[0m'
ORANGE='\033[38;2;237;177;72m'
GRAY='\033[90m'
# Clear screen and show welcome banner
clear
echo -e "$RESET$ORANGE"
echo -e " 🌈 Your Dev Environment is prepared."
echo -e ""
echo -e "Quick Commands:$RESET"
echo -e " $GRAY▶$RESET $CYAN nix flake show$RESET - Show available configurations"
echo -e " $GRAY▶$RESET $CYAN nix flake check$RESET - Run all checks"
echo -e "$RESET$ORANGE \n__________________________________________________________________\n"
echo ""
'';
};
});
};
}

Loading
Loading