diff --git a/pkgs/by-name/fr/froide-govplan/load_extra_settings.patch b/pkgs/by-name/fr/froide-govplan/load_extra_settings.patch new file mode 100644 index 0000000000000..5f1defcdcd1ae --- /dev/null +++ b/pkgs/by-name/fr/froide-govplan/load_extra_settings.patch @@ -0,0 +1,15 @@ +diff --git a/project/settings.py b/project/settings.py +index dd282ac..64ff265 100644 +--- a/project/settings.py ++++ b/project/settings.py +@@ -202,3 +202,10 @@ CMS_CONFIRM_VERSION4 = True + + GOVPLAN_NAME = "GovPlan" + GOVPLAN_ENABLE_FOIREQUEST = False ++ ++EXTRA_SETTINGS_PATH = os.path.join(PROJECT_DIR, 'extra_settings.py') ++ ++if os.path.exists(EXTRA_SETTINGS_PATH): ++ with open(EXTRA_SETTINGS_PATH) as f: ++ code = compile(f.read(), EXTRA_SETTINGS_PATH, 'exec') ++ exec(code) diff --git a/pkgs/by-name/fr/froide-govplan/package.nix b/pkgs/by-name/fr/froide-govplan/package.nix new file mode 100644 index 0000000000000..ed1df930ebdee --- /dev/null +++ b/pkgs/by-name/fr/froide-govplan/package.nix @@ -0,0 +1,104 @@ +{ + lib, + python3, + fetchFromGitHub, + makeWrapper, + froide, + gdal, + geos, + nixosTests, + fetchpatch, +}: + +let + + python = python3.override { + packageOverrides = self: super: { + django = super.django.override { withGdal = true; }; + }; + }; + +in +python.pkgs.buildPythonApplication rec { + pname = "froide-govplan"; + version = "0-unstable-2024-11-05"; + pyproject = true; + + src = fetchFromGitHub { + owner = "okfde"; + repo = "froide-govplan"; + # No tagged release yet + # https://github.com/okfde/froide-govplan/issues/15 + rev = "5d2f5e6c0bc883c75a00e45893f3e32761d3159f"; + hash = "sha256-hVZL8WMY0xorZv8k0qQ2Q7etJnwrl/CTKXkcQiLN+RQ="; + }; + + patches = [ + # Add missing oauth2_provider app + # https://github.com/okfde/froide-govplan/pull/17 + (fetchpatch { + url = "https://github.com/okfde/froide-govplan/commit/bc388b693ebc7656fc7917511048a47b68e119fe.patch"; + hash = "sha256-StIyN3gFKd/fld14s03fsV6fmWinSRWINUyRRBzqVco="; + name = "add_oauth2_provider_app.patch"; + }) + # Enable automatic image cropping for filer + # https://github.com/okfde/froide-govplan/pull/19 + (fetchpatch { + url = "https://github.com/okfde/froide-govplan/commit/d5db02f3bbc501929a901e964147a0ed2f974f41.patch"; + hash = "sha256-jf6e84fd2kQIPER2HGmZNkbtl067311xdNJRU+iFVXM="; + name = "filer_enable_automatic_cropping.patch"; + }) + + # Patch settings.py to source additional settings from the NixOS module + ./load_extra_settings.patch + ]; + + 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 + (toPythonModule (froide.override { python3Packages = python.pkgs; })) + 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/ + cp -r project $out/${python.sitePackages}/ + 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" + ''; + + passthru = { + tests = { + inherit (nixosTests) froide-govplan; + }; + python = python; + pythonPath = python.pkgs.makePythonPath dependencies; + }; + + meta = { + description = "Government planner and basis of FragDenStaat.de Koalitionstracker"; + homepage = "https://github.com/okfde/froide-govplan"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.onny ]; + mainProgram = "froide-govplan"; + }; + +}