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

froide-govplan: init at 0-unstable-2024-09-19 #349750

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@
./services/web-apps/flarum.nix
./services/web-apps/fluidd.nix
./services/web-apps/freshrss.nix
./services/web-apps/froide-govplan.nix
./services/web-apps/galene.nix
./services/web-apps/gancio.nix
./services/web-apps/gerrit.nix
Expand Down
112 changes: 112 additions & 0 deletions nixos/modules/services/web-apps/froide-govplan.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
config,
lib,
pkgs,
...
}:
let

cfg = config.services.froide-govplan;
format = pkgs.formats.toml { };

in {
options.services.froide-govplan = {

enable = lib.mkEnableOption "Gouvernment planer web app Govplan";

settings = lib.mkOption {
default = { };
description = ''
IMAP authentication configuration for rspamd-trainer. For supplying
the IMAP password, use the `secrets` option.
'';
type = lib.types.submodule {
freeformType = format.type;
};
example = lib.literalExpression ''
{
HOST = "localhost";
USERNAME = "[email protected]";
INBOXPREFIX = "INBOX/";
}
'';
};

secrets = lib.mkOption {
type = with lib.types; listOf path;
description = ''
A list of files containing the various secrets. Should be in the
format expected by systemd's `EnvironmentFile` directory. For the
IMAP account password use `PASSWORD = mypassword`.
'';
default = [ ];
};

};

config = lib.mkIf cfg.enable {

services.postgresql = {
enable = true;
ensureDatabases = [ "govplan" ];
ensureUsers = [
{ name = "govplan";
ensureDBOwnership = true;
}
];
extraPlugins = ps: with ps; [ postgis ];
authentication = ''
host govplan govplan localhost trust
'';
initialScript = pkgs.writeText "backend-initScript" ''
ALTER USER govplan WITH SUPERUSER;
'';
};

systemd = {
services = {

postgresql.serviceConfig.ExecStartPost =
let
sqlFile = pkgs.writeText "immich-pgvectors-setup.sql" ''
ALTER USER govplan WITH SUPERUSER;
#CREATE EXTENSION IF NOT EXISTS postgis;
#ALTER SCHEMA govplan OWNER TO govplan;
#ALTER EXTENSION govplan UPDATE;
'';
in
[
''
${lib.getExe' config.services.postgresql.package "psql"} -d govplan -f "${sqlFile}"
''
];

froide-govplan = {
description = "Gouvernment planer Govplan";
serviceConfig = {
ExecStart = "${pkgs.froide-govplan}/bin/froide-govplan runserver 0.0.0.0:8000";
WorkingDirectory = "/var/lib/froide-govplan";
StateDirectory = [ "froide-govplan" ];
DynamicUser = true;
EnvironmentFile = [
( format.generate "froide-govplan-env" cfg.settings )
cfg.secrets
];
};
after = [ "postgresql.service" ];
wantedBy = [ "multi-user.target" ];
preStart = ''
# FIXME adapt paperless-ngx check for new versions
${pkgs.froide-govplan}/bin/froide-govplan migrate
${pkgs.froide-govplan}/bin/froide-govplan migrate djangocms_alias
'';
};
};

};

};

meta.maintainers = with lib.maintainers; [ onny ];

}
41 changes: 41 additions & 0 deletions pkgs/by-name/fr/froide-govplan/cms-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/froide_govplan/templates/admin/froide_govplan/governmentplan/change_form.html b/froide_govplan/templates/admin/froide_govplan/governmentplan/change_form.html
index b512140..33e88cc 100644
--- a/froide_govplan/templates/admin/froide_govplan/governmentplan/change_form.html
+++ b/froide_govplan/templates/admin/froide_govplan/governmentplan/change_form.html
@@ -9,5 +9,7 @@
</a>
</li>
{% endif %}
- {{ block.super }}
+ {% if block.super %}
+ {{ block.super }}
+ {% endif %}
{% endblock %}
diff --git a/froide_govplan/templates/froide_govplan/admin/accept_proposal.html b/froide_govplan/templates/froide_govplan/admin/accept_proposal.html
index 24f2b14..98ad5c4 100644
--- a/froide_govplan/templates/froide_govplan/admin/accept_proposal.html
+++ b/froide_govplan/templates/froide_govplan/admin/accept_proposal.html
@@ -1,7 +1,7 @@
{% extends "admin/change_form.html" %}
{% load i18n %}

-{% block title %}{{ object.title }} - {{ block.super }}{% endblock %}
+{% block title %}{{ object.title }} - {% if block.super %}{{ block.super }}{% endif %}{% endblock %}


{% block content %}<div id="content-main">
diff --git a/froide_govplan/templates/froide_govplan/base.html b/froide_govplan/templates/froide_govplan/base.html
index fa9711e..1cd9773 100644
--- a/froide_govplan/templates/froide_govplan/base.html
+++ b/froide_govplan/templates/froide_govplan/base.html
@@ -3,7 +3,9 @@
{% load djangocms_alias_tags %}
{% load menu_tags %}
{% block navbar %}
- {{ block.super }}
+ {% if block.super %}
+ {{ block.super }}
+ {% endif %}
{% include "snippets/breadcrumbs.html" with breadcrumbs_background="blue-10" overlay=True %}
{% endblock navbar %}
{% block body %}
70 changes: 70 additions & 0 deletions pkgs/by-name/fr/froide-govplan/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
python3,
fetchFromGitHub,
makeWrapper,
froide,
gdal,
geos,
}:

let

python = python3.override {
packageOverrides = self: super: {
django = super.django_5.override { withGdal = true; };
};
};

in
python.pkgs.buildPythonApplication rec {
pname = "froide-govplan";
version = "0-unstable-2024-09-19";
pyproject = true;

src = fetchFromGitHub {
owner = "okfde";
repo = "froide-govplan";
# No tagged release yet
# https://github.com/okfde/froide-govplan/issues/15
rev = "eb0908dea9ecc64b23ca8a2bc550fcb1a400e3f1";
hash = "sha256-4lBxIvNRr7/Jf2fV8Aaz9plOOK0tArIzyUfHDZTuE9c=";
};

patches = [ ./cms-fix.patch ];

postPatch = ''
sed -i '$a CMS_CONFIRM_VERSION4 = True' project/settings.py
sed -i '63i\ "parler",\n "djangocms_alias",' project/settings.py
'';

build-system = [ python.pkgs.setuptools ];

build-inputs = [ gdal ];

nativeBuildInputs = [ makeWrapper ];

dependencies = with python.pkgs; [
bleach
django-admin-sortable2
django-cms
django-filer
django-mfa3
django-oauth-toolkit
django-tinymce
psycopg
froide
django-mptt
django-sekizai
django-treebeard
djangocms-alias
];

postInstall = ''
cp manage.py $out/${python.sitePackages}/froide_govplan/
cp -r project $out/${python.sitePackages}/froide_govplan/
makeWrapper $out/${python.sitePackages}/froide_govplan/manage.py $out/bin/froide-govplan \
--prefix PYTHONPATH : "$PYTHONPATH" \
--set GDAL_LIBRARY_PATH "${gdal}/lib/libgdal.so" \
--set GEOS_LIBRARY_PATH "${geos}/lib/libgeos_c.so"
'';
}
80 changes: 80 additions & 0 deletions pkgs/by-name/fr/froide/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
python3,
fetchFromGitHub,
makeWrapper,
}:
let

python = python3.override {
packageOverrides = self: super: {
django = super.django_5.override { withGdal = true; };
};
};

in
python.pkgs.buildPythonApplication rec {
pname = "froide";
version = "0-unstable-2024-11-01";
pyproject = true;

src = fetchFromGitHub {
owner = "okfde";
repo = "froide";
rev = "473c57e3eb8c99fad13635331f37eb6d4dac9bf5";
hash = "sha256-U9Nphf4b6WFoWnguyHTSGgrrXZxEQraFlk4c5bPwzAs=";
# Tmp downgrade to tag on july
#rev = "a78a4054f9f37b0a5109a6d8cfbbda742f86a8ca";
#hash = "sha256-gtOssbsVf3nG+pmLPgvh4685vHh2x+jlXiTjU+JhQa8=";
};

pythonRelaxDeps = [
"django"
"pikepdf"
"channels"
];

build-system = [ python.pkgs.setuptools ];

nativeBuildInputs = [ makeWrapper ];

dependencies = with python.pkgs; [
celery
celery-singleton
coreapi
dj-database-url
django-configurations
django-crossdomainmedia
django-elasticsearch-dsl
django-filingcabinet
django-filter
django-leaflet
django-parler
django-storages
django-taggit
djangorestframework-csv
djangorestframework-jsonp
drf-spectacular
easy-thumbnails
geoip2
icalendar
markdown
phonenumbers
pygtail
python-magic
python-mimeparse
python-slugify
requests

psycopg
websockets
pyisemail
weasyprint
django-mfa3
bleach
channels
django-celery-email
django-celery-beat
django-oauth-toolkit
django-contrib-comments
];
}
28 changes: 17 additions & 11 deletions pkgs/development/libraries/gdal/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib
, gcc11Stdenv
, stdenv
, callPackage
, fetchFromGitHub
Expand Down Expand Up @@ -77,10 +78,12 @@
, zlib
, zstd
}:

#let
# stdenv = gcc11Stdenv;
#in
stdenv.mkDerivation (finalAttrs: {
pname = "gdal" + lib.optionalString useMinimalFeatures "-minimal";
version = "3.9.3";
version = "3.8.0";

src = fetchFromGitHub {
owner = "OSGeo";
Expand All @@ -105,25 +108,26 @@ stdenv.mkDerivation (finalAttrs: {
python3.pkgs.setuptools
python3.pkgs.wrapPython
swig
] ++ lib.optionals useJava [ ant jdk ];
]; # ++ lib.optionals useJava [ ant jdk ];

cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-fpermissive"
"-DGDAL_USE_INTERNAL_LIBS=OFF"
"-DGEOTIFF_INCLUDE_DIR=${lib.getDev libgeotiff}/include"
"-DGEOTIFF_LIBRARY_RELEASE=${lib.getLib libgeotiff}/lib/libgeotiff${stdenv.hostPlatform.extensions.sharedLibrary}"
"-DMYSQL_INCLUDE_DIR=${lib.getDev libmysqlclient}/include/mysql"
"-DMYSQL_LIBRARY=${lib.getLib libmysqlclient}/lib/${lib.optionalString (libmysqlclient.pname != "mysql") "mysql/"}libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary}"
] ++ lib.optionals finalAttrs.doInstallCheck [
"-DBUILD_TESTING=ON"
#] ++ lib.optionals finalAttrs.doInstallCheck [
# "-DBUILD_TESTING=ON"
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
"-DCMAKE_SKIP_BUILD_RPATH=ON" # without, libgdal.so can't find libmariadb.so
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON"
] ++ lib.optionals (!useTiledb) [
"-DGDAL_USE_TILEDB=OFF"
] ++ lib.optionals (!useJava) [
# This is not strictly needed as the Java bindings wouldn't build anyway if
# ant/jdk were not available.
#] ++ lib.optionals (!useJava) [
# # This is not strictly needed as the Java bindings wouldn't build anyway if
# # ant/jdk were not available.
"-DBUILD_JAVA_BINDINGS=OFF"
];

Expand Down Expand Up @@ -193,8 +197,8 @@ stdenv.mkDerivation (finalAttrs: {
zstd
python3
python3.pkgs.numpy
] ++ tileDbDeps
++ libHeifDeps
] #++ tileDbDeps
#++ libHeifDeps
++ libJxlDeps
++ mysqlDeps
++ postgresDeps
Expand All @@ -217,7 +221,7 @@ stdenv.mkDerivation (finalAttrs: {

enableParallelBuilding = true;

doInstallCheck = true;
#doInstallCheck = true;
# preCheck rather than preInstallCheck because this is what pytestCheckHook
# calls (coming from the python world)
preCheck = ''
Expand Down Expand Up @@ -282,6 +286,8 @@ stdenv.mkDerivation (finalAttrs: {
popd # autotest
'';

doCheck = false;

passthru.tests = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };

__darwinAllowLocalNetworking = true;
Expand Down
Loading
Loading