From 986d00236a2b978f041cc96088a15133c925fdb9 Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Tue, 8 Jul 2025 12:02:39 -0400 Subject: [PATCH 1/2] liberaforms: init at 4.1.2 Signed-off-by: Ethan Carter Edwards (cherry picked from commit e4bd3e7849742a31506ac2fa86bf0086a5c0573d) --- pkgs/by-name/li/liberaforms/package.nix | 265 ++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 pkgs/by-name/li/liberaforms/package.nix diff --git a/pkgs/by-name/li/liberaforms/package.nix b/pkgs/by-name/li/liberaforms/package.nix new file mode 100644 index 0000000000000..5ecb5fdb1c1c5 --- /dev/null +++ b/pkgs/by-name/li/liberaforms/package.nix @@ -0,0 +1,265 @@ +{ + lib, + python3Packages, + fetchFromGitea, + fetchPypi, + fetchFromGitHub, + callPackage, + + postgresql, + libxml2, + libxslt, + + # tests + postgresqlTestHook, +}: + +let + # liberaforms requires a very specific version of flask-babel + flask-babel = python3Packages.flask-babel.overridePythonAttrs rec { + version = "2.0.0"; + format = "setuptools"; + src = fetchPypi { + pname = "Flask-Babel"; + inherit version; + hash = "sha256-+fr0XNsuGjLqLsFEA1h9QpUQjzUBenghorGsuM/ZJX0="; + }; + nativeBuildInputs = [ ]; + propagatedBuildInputs = [ ]; + outputs = [ "out" ]; + dependencies = with python3Packages; [ + babel + flask + jinja2 + pytz + ]; + pythonImportsCheck = [ ]; + checkInputs = [ ]; + }; + # same with flask + flask = python3Packages.flask.overridePythonAttrs rec { + version = "2.2.2"; + pyproject = null; + format = "setuptools"; + src = fetchPypi { + pname = "Flask"; + inherit version; + hash = "sha256-ZCxFDRnErUgvlnKb0qj20yVUqh4jH09rTn5SZLFsyis="; + }; + dependencies = (with python3Packages; [ + click + blinker + itsdangerous + jinja2 + ] ++ [ werkzeug ]); + nativeCheckInputs = [ ]; + }; + # same with werkzeug + werkzeug = python3Packages.werkzeug.overridePythonAttrs rec { + version = "2.2.2"; + pyproject = null; + format = "setuptools"; + src = fetchPypi { + pname = "Werkzeug"; + inherit version; + hash = "sha256-fqLUgyLMfA+LOiFe1z6r17XXXQtQ4xqwBihsz/ngC48="; + }; + nativeCheckInputs = [ ]; + }; + sqlalchemy_1_4 = python3Packages.sqlalchemy_1_4.overridePythonAttrs rec { + version = "1.4.42"; + src = fetchFromGitHub { + owner = "sqlalchemy"; + repo = "sqlalchemy"; + rev = "rel_${lib.replaceStrings [ "." ] [ "_" ] version}"; + hash = "sha256-RVpreszvd5hn9BLzvnfKT4nibUuybtZwBRloe5NaP/E="; + }; + env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration"; + disabledTestPaths = [ + # typing correctness, not interesting + "test/ext/mypy" + # slow and high memory usage, not interesting + "test/aaa_profiling" + # fetching and key slice failures, probably network related + "test/base/test_result.py" + "test/dialect/test_sqlite.py" + "test/ext/test_baked.py" + "test/ext/test_horizontal_shard.py" + "test/ext/test_hybrid.py" + "test/orm/" + "test/sql/test_resultset.py" + ]; + }; +in + +python3Packages.buildPythonPackage rec { + pname = "liberaforms"; + version = "4.1.2"; + format = "other"; + + src = fetchFromGitea { + domain = "codeberg.org"; + owner = "LiberaForms"; + repo = "server"; + tag = "v${version}"; + hash = "sha256-OALAoaIbUPD9qrtxraoG50/lkUvShHq0n5d8etkSliI="; + }; + + build-system = with python3Packages; [ + setuptools + setuptools-scm + ]; + + dependencies = with python3Packages; [ + aiosmtpd + alembic + atpublic + attrs + babel + beautifulsoup4 + bleach + cairosvg + cachelib + certifi + cffi + charset-normalizer + click + cryptography + deepdiff + dnspython + email-validator + feedgen + flask + flask-babel + flask-login + flask-marshmallow + flask-migrate + flask-session2 + flask-session + flask-sqlalchemy + flask-wtf + greenlet + gunicorn + idna + importlib-metadata + importlib-resources + iniconfig + itsdangerous + jinja2 + ldap3 + lxml + mako + markdown + markupsafe + marshmallow + marshmallow-sqlalchemy + minio + packaging + passlib + password-strength + password-entropy + pillow + platformdirs + pluggy + portpicker + prometheus-client + psutil + psycopg2 + py + pyasn1 + pycodestyle + pycparser + pygments + pyjwt + pyparsing + pypng + pyqrcode + python-dateutil + python-dotenv + python-magic + pytz + requests + six + smtpdfix + snowballstemmer + soupsieve + sqlalchemy_1_4 + sqlalchemy-json + toml + unicodecsv + unidecode + urllib3 + webencodings + werkzeug + wtforms + zipp + ]; + + pythonRemoveDeps = [ + # removed + "typed-ast" + ]; + + nativeBuildInputs = [ + postgresql + libxml2 + libxslt + ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + cp -R ${src}/. $out + + runHook postInstall + ''; + + doCheck = true; + + nativeCheckInputs = + [ + postgresql + postgresqlTestHook + ] + ++ (with python3Packages; [ + faker + pytestCheckHook + pytest-dotenv + factory-boy + polib + ]); + + preCheck = '' + export LANG=C.UTF-8 + export PGUSER=db_user + export postgresqlEnableTCP=1 + ''; + + checkPhase = '' + runHook preCheck + + # Run pytest on the installed version. A running postgres database server is needed. + (cd tests && cp test.ini.example test.ini && pytest -k "not test_save_smtp_config and not test/ext/test_horizontal_shard.py\ + and not TestE2EEDisabledFeatures") #TODO why does this break? + + runHook postCheck + ''; + + # avoid writing in the migration process + postFixup = '' + cp $out/assets/brand/logo-default.png $out/assets/brand/logo.png + cp $out/assets/brand/favicon-default.ico $out/assets/brand/favicon.ico + sed -i "/shutil.copyfile/d" $out/liberaforms/models/site.py + sed -i "/brand_dir/d" $out/migrations/versions/6f0e2b9e9db3_.py + ''; + + meta = { + description = "Free form software"; + homepage = "https://gitlab.com/liberaforms/liberaforms"; + license = lib.licenses.agpl3Plus; + platforms = lib.platforms.all; + }; +} From 8c3a8527af1fbe497f2a665c73e7b5caa9859413 Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Mon, 23 Mar 2026 21:45:15 +0530 Subject: [PATCH 2/2] liberaforms: 4.1.2 -> 4.8.1 Signed-off-by: phanirithvij --- pkgs/by-name/li/liberaforms/package.nix | 225 ++++++++++++------------ 1 file changed, 111 insertions(+), 114 deletions(-) diff --git a/pkgs/by-name/li/liberaforms/package.nix b/pkgs/by-name/li/liberaforms/package.nix index 5ecb5fdb1c1c5..955e25261e3dc 100644 --- a/pkgs/by-name/li/liberaforms/package.nix +++ b/pkgs/by-name/li/liberaforms/package.nix @@ -1,11 +1,12 @@ { lib, - python3Packages, + python3, fetchFromGitea, - fetchPypi, fetchFromGitHub, - callPackage, + fetchPypi, + moreutils, + dart-sass, postgresql, libxml2, libxslt, @@ -15,96 +16,101 @@ }: let - # liberaforms requires a very specific version of flask-babel - flask-babel = python3Packages.flask-babel.overridePythonAttrs rec { - version = "2.0.0"; - format = "setuptools"; - src = fetchPypi { - pname = "Flask-Babel"; - inherit version; - hash = "sha256-+fr0XNsuGjLqLsFEA1h9QpUQjzUBenghorGsuM/ZJX0="; - }; - nativeBuildInputs = [ ]; - propagatedBuildInputs = [ ]; - outputs = [ "out" ]; - dependencies = with python3Packages; [ - babel - flask - jinja2 - pytz - ]; - pythonImportsCheck = [ ]; - checkInputs = [ ]; - }; - # same with flask - flask = python3Packages.flask.overridePythonAttrs rec { - version = "2.2.2"; - pyproject = null; - format = "setuptools"; - src = fetchPypi { - pname = "Flask"; - inherit version; - hash = "sha256-ZCxFDRnErUgvlnKb0qj20yVUqh4jH09rTn5SZLFsyis="; - }; - dependencies = (with python3Packages; [ - click - blinker - itsdangerous - jinja2 - ] ++ [ werkzeug ]); - nativeCheckInputs = [ ]; - }; - # same with werkzeug - werkzeug = python3Packages.werkzeug.overridePythonAttrs rec { - version = "2.2.2"; - pyproject = null; - format = "setuptools"; - src = fetchPypi { - pname = "Werkzeug"; - inherit version; - hash = "sha256-fqLUgyLMfA+LOiFe1z6r17XXXQtQ4xqwBihsz/ngC48="; - }; - nativeCheckInputs = [ ]; - }; - sqlalchemy_1_4 = python3Packages.sqlalchemy_1_4.overridePythonAttrs rec { - version = "1.4.42"; - src = fetchFromGitHub { - owner = "sqlalchemy"; - repo = "sqlalchemy"; - rev = "rel_${lib.replaceStrings [ "." ] [ "_" ] version}"; - hash = "sha256-RVpreszvd5hn9BLzvnfKT4nibUuybtZwBRloe5NaP/E="; + python = python3.override { + packageOverrides = self: super: { + # required 1.8.1 (tests fail otherwise) + alembic = super.alembic.overridePythonAttrs rec { + pname = "alembic"; + version = "1.8.1"; + src = fetchPypi { + inherit pname version; + sha256 = "sha256-zQteRbFLcGQmuDPwY2m5ptXuA/gm7DI4cjzoyq9uX/o="; + }; + doCheck = false; + }; + # required 3.1.0 (requirements and 3.1.0 works with alembic 1.8.1) + flask-migrate = super.flask-migrate.overridePythonAttrs rec { + version = "3.1.0"; + src = fetchFromGitHub { + owner = "miguelgrinberg"; + repo = "Flask-Migrate"; + tag = "v${version}"; + hash = "sha256-2P9UfR/1Vv9FSmpSZn0gV4/uuSNdl6sdgRnSbefFR34="; + }; + dependencies = [ + self.alembic + super.flask + self.flask-sqlalchemy + ]; + nativeCheckInputs = [ ]; + }; + # required downgrade to 3.0.2 (from requirements.txt as well as sqlalchemy downgrade) + flask-sqlalchemy = super.flask-sqlalchemy.overridePythonAttrs rec { + version = "3.0.2"; + src = fetchPypi { + pname = "Flask-SQLAlchemy"; + inherit version; + hash = "sha256-FhmfWz3ftp4N8vUq5Mdq7b/sgjRiNJ2rshobLgorZek="; + }; + dependencies = [ + super.flask + self.sqlalchemy + super.pdm-pep517 + ]; + }; + # required 1.4.42 (from requirements) + sqlalchemy = super.sqlalchemy_1_4.overridePythonAttrs rec { + version = "1.4.42"; + src = fetchFromGitHub { + owner = "sqlalchemy"; + repo = "sqlalchemy"; + rev = "rel_${lib.replaceStrings [ "." ] [ "_" ] version}"; + hash = "sha256-RVpreszvd5hn9BLzvnfKT4nibUuybtZwBRloe5NaP/E="; + }; + disabledTestPaths = [ + # typing correctness, not interesting + "test/ext/mypy" + # slow and high memory usage, not interesting + "test/aaa_profiling" + # fetching and key slice failures, probably network related + "test/base/test_result.py" + "test/dialect/test_sqlite.py" + "test/ext/test_baked.py" + "test/ext/test_horizontal_shard.py" + "test/ext/test_hybrid.py" + "test/orm/" + "test/sql/test_resultset.py" + ]; + }; + }; - env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration"; - disabledTestPaths = [ - # typing correctness, not interesting - "test/ext/mypy" - # slow and high memory usage, not interesting - "test/aaa_profiling" - # fetching and key slice failures, probably network related - "test/base/test_result.py" - "test/dialect/test_sqlite.py" - "test/ext/test_baked.py" - "test/ext/test_horizontal_shard.py" - "test/ext/test_hybrid.py" - "test/orm/" - "test/sql/test_resultset.py" - ]; }; + python3Packages = python.pkgs; in -python3Packages.buildPythonPackage rec { +python3Packages.buildPythonPackage (finalAttrs: { pname = "liberaforms"; - version = "4.1.2"; + version = "4.8.1"; format = "other"; src = fetchFromGitea { domain = "codeberg.org"; owner = "LiberaForms"; repo = "server"; - tag = "v${version}"; - hash = "sha256-OALAoaIbUPD9qrtxraoG50/lkUvShHq0n5d8etkSliI="; + tag = "v${finalAttrs.version}"; + hash = "sha256-rXQxDSMh15CicePCA+nOERE+EBE4SQR0gsUacu1jV98="; }; + strictDeps = true; + __structuredAttrs = true; + + postPatch = '' + echo "Compiling sass files" + pushd liberaforms/static + chronic sass sass:css --style=compressed --no-source-map + popd + ''; + build-system = with python3Packages; [ setuptools setuptools-scm @@ -130,12 +136,12 @@ python3Packages.buildPythonPackage rec { email-validator feedgen flask + flask-assets flask-babel flask-login flask-marshmallow flask-migrate flask-session2 - flask-session flask-sqlalchemy flask-wtf greenlet @@ -156,7 +162,6 @@ python3Packages.buildPythonPackage rec { minio packaging passlib - password-strength password-entropy pillow platformdirs @@ -183,7 +188,7 @@ python3Packages.buildPythonPackage rec { smtpdfix snowballstemmer soupsieve - sqlalchemy_1_4 + sqlalchemy sqlalchemy-json toml unicodecsv @@ -195,12 +200,9 @@ python3Packages.buildPythonPackage rec { zipp ]; - pythonRemoveDeps = [ - # removed - "typed-ast" - ]; - nativeBuildInputs = [ + dart-sass + moreutils # chronic postgresql libxml2 libxslt @@ -212,40 +214,32 @@ python3Packages.buildPythonPackage rec { installPhase = '' runHook preInstall - cp -R ${src}/. $out + cp -R . $out runHook postInstall ''; doCheck = true; - nativeCheckInputs = - [ - postgresql - postgresqlTestHook - ] - ++ (with python3Packages; [ - faker - pytestCheckHook - pytest-dotenv - factory-boy - polib - ]); + nativeCheckInputs = [ + postgresql + postgresqlTestHook + ] + ++ (with python3Packages; [ + faker + pytestCheckHook + pytest-dotenv + factory-boy + polib + ]); + # Run pytest on the installed version. A running postgres database server is needed. preCheck = '' export LANG=C.UTF-8 export PGUSER=db_user export postgresqlEnableTCP=1 - ''; - - checkPhase = '' - runHook preCheck - - # Run pytest on the installed version. A running postgres database server is needed. - (cd tests && cp test.ini.example test.ini && pytest -k "not test_save_smtp_config and not test/ext/test_horizontal_shard.py\ - and not TestE2EEDisabledFeatures") #TODO why does this break? - - runHook postCheck + pushd tests + cp test.ini.example test.ini ''; # avoid writing in the migration process @@ -257,9 +251,12 @@ python3Packages.buildPythonPackage rec { ''; meta = { - description = "Free form software"; - homepage = "https://gitlab.com/liberaforms/liberaforms"; + description = "Ethical form software"; + homepage = "https://liberaforms.org"; + downloadPage = "https://codeberg.org/LiberaForms/server"; license = lib.licenses.agpl3Plus; platforms = lib.platforms.all; + # no mainProgram + teams = with lib.teams; [ ngi ]; }; -} +})