From 48932d34080693ae5ec7de428cd696d58a8b1127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 7 Nov 2022 23:45:26 +0100 Subject: [PATCH 1/4] python310Packages.jinja2-time: normalise attr and path, enable tests, cleanups --- .../python-modules/cookiecutter/default.nix | 4 ++-- .../{jinja2_time => jinja2-time}/default.nix | 19 +++++++++++++++++-- pkgs/top-level/python-aliases.nix | 1 + pkgs/top-level/python-packages.nix | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) rename pkgs/development/python-modules/{jinja2_time => jinja2-time}/default.nix (51%) diff --git a/pkgs/development/python-modules/cookiecutter/default.nix b/pkgs/development/python-modules/cookiecutter/default.nix index fdad4febcdaf..ce6912f34a98 100644 --- a/pkgs/development/python-modules/cookiecutter/default.nix +++ b/pkgs/development/python-modules/cookiecutter/default.nix @@ -1,6 +1,6 @@ { lib, buildPythonPackage, fetchPypi, isPyPy , pytest, pytest-cov, pytest-mock, freezegun -, jinja2, future, binaryornot, click, jinja2_time, requests +, jinja2, future, binaryornot, click, jinja2-time, requests , python-slugify , pyyaml }: @@ -23,7 +23,7 @@ buildPythonPackage rec { jinja2 click pyyaml - jinja2_time + jinja2-time python-slugify requests ]; diff --git a/pkgs/development/python-modules/jinja2_time/default.nix b/pkgs/development/python-modules/jinja2-time/default.nix similarity index 51% rename from pkgs/development/python-modules/jinja2_time/default.nix rename to pkgs/development/python-modules/jinja2-time/default.nix index 4268413fd3f5..ac0d76c54c55 100644 --- a/pkgs/development/python-modules/jinja2_time/default.nix +++ b/pkgs/development/python-modules/jinja2-time/default.nix @@ -1,25 +1,40 @@ { lib , buildPythonPackage +, fetchpatch , fetchPypi , arrow +, freezegun , jinja2 +, pytestCheckHook }: buildPythonPackage rec { - version = "0.2.0"; pname = "jinja2-time"; + version = "0.2.0"; src = fetchPypi { inherit pname version; sha256 = "0h0dr7cfpjnjj8bgl2vk9063a53649pn37wnlkd8hxjy656slkni"; }; + patches = [ + # fix usage of arrow in tests + (fetchpatch { + url = "https://github.com/hackebrot/jinja2-time/pull/19/commits/3b2476c266ba53262352153104ca3501722823a4.patch"; + sha256 = "sha256-zh4PpAj2GtpgaEap/Yvu6DNY84AwH/YTJlUPRRHPyTs="; + }) + ]; + propagatedBuildInputs = [ arrow jinja2 ]; + checkInputs = [ freezegun pytestCheckHook ]; + + pythonImportsCheck = [ "jinja2_time" ]; + meta = with lib; { homepage = "https://github.com/hackebrot/jinja2-time"; description = "Jinja2 Extension for Dates and Times"; license = licenses.mit; + maintainers = with maintainers; [ ]; }; - } diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index 8a33d02ba1a3..864d0d45b2fa 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -100,6 +100,7 @@ mapAliases ({ ipaddress = throw "ipaddress has been removed because it is no longer required since python 2.7."; # added 2022-05-30 influxgraph = throw "influxgraph has been removed because it is no longer maintained"; # added 2022-07-10 itanium_demangler = itanium-demangler; # added 2022-1017 + jinja2_time = jinja2-time; # added 2022-11-07 jupyter_client = jupyter-client; # added 2021-10-15 Keras = keras; # added 2021-11-25 ldap = python-ldap; # added 2022-09-16 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 3810767e7d2a..b87d4a5df98d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4722,7 +4722,7 @@ self: super: with self; { jinja2_pluralize = callPackage ../development/python-modules/jinja2_pluralize { }; - jinja2_time = callPackage ../development/python-modules/jinja2_time { }; + jinja2-time = callPackage ../development/python-modules/jinja2-time { }; jira = callPackage ../development/python-modules/jira { }; From dd538e9aed4211008aac6b65d771470d896a6c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 8 Nov 2022 00:44:56 +0100 Subject: [PATCH 2/4] python310Packages.jq: 1.2.3 -> 1.3.0 --- .../development/python-modules/jq/default.nix | 24 ++++-- .../python-modules/jq/jq-py-setup.patch | 77 ++++++------------- 2 files changed, 39 insertions(+), 62 deletions(-) diff --git a/pkgs/development/python-modules/jq/default.nix b/pkgs/development/python-modules/jq/default.nix index 4d0ac3ebd8f7..b5ec35717733 100644 --- a/pkgs/development/python-modules/jq/default.nix +++ b/pkgs/development/python-modules/jq/default.nix @@ -1,12 +1,14 @@ -{ buildPythonPackage, fetchPypi, lib, jq }: +{ lib, buildPythonPackage, fetchFromGitHub, cython, jq, pytestCheckHook }: buildPythonPackage rec { pname = "jq"; - version = "1.2.3"; + version = "1.3.0"; - src = fetchPypi { - inherit pname version; - sha256 = "sha256-15bXqaa6c6RMoHKqUAcOhPrhMBbqYHrDdnZAaFaHElc="; + src = fetchFromGitHub { + owner = "mwilliamson"; + repo = "jq.py"; + rev = version; + sha256 = "sha256-1EQm5ShjFHbO1IO5QD42fsGHFGDBrJulLrcl+WeU7wo="; }; patches = [ @@ -14,10 +16,18 @@ buildPythonPackage rec { ./jq-py-setup.patch ]; + nativeBuildInputs = [ cython ]; + buildInputs = [ jq ]; - # no tests executed - doCheck = false; + preBuild = '' + cython jq.pyx + ''; + + checkInputs = [ + pytestCheckHook + ]; + pythonImportsCheck = [ "jq" ]; meta = { diff --git a/pkgs/development/python-modules/jq/jq-py-setup.patch b/pkgs/development/python-modules/jq/jq-py-setup.patch index cf8713796751..0894b776fef6 100644 --- a/pkgs/development/python-modules/jq/jq-py-setup.patch +++ b/pkgs/development/python-modules/jq/jq-py-setup.patch @@ -1,17 +1,8 @@ -From bef841b73ba7c9a79211146798ac888fce9bb55a Mon Sep 17 00:00:00 2001 -From: "Robert T. McGibbon" -Date: Fri, 7 May 2021 19:14:20 -0400 -Subject: [PATCH 1/1] Vastly simplify setup.py for distro compatibility - ---- - setup.py | 98 +------------------------------------------------------- - 1 file changed, 1 insertion(+), 97 deletions(-) - diff --git a/setup.py b/setup.py -index 663792c..3ebcabe 100644 +index 01cc813..15e9048 100644 --- a/setup.py +++ b/setup.py -@@ -1,113 +1,19 @@ +@@ -1,97 +1,18 @@ #!/usr/bin/env python import os @@ -20,50 +11,42 @@ index 663792c..3ebcabe 100644 -import shutil -import sysconfig --import requests from setuptools import setup -from setuptools.command.build_ext import build_ext from setuptools.extension import Extension - --def urlretrieve(source_url, destination_path): -- response = requests.get(source_url, stream=True) -- if response.status_code != 200: -- raise Exception("status code was: {}".format(response.status_code)) - -- with open(destination_path, "wb") as fileobj: -- for chunk in response.iter_content(chunk_size=128): -- fileobj.write(chunk) -- --def path_in_dir(relative_path): +-def _path_in_dir(relative_path): - return os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path)) - --def dependency_path(relative_path): -- return os.path.join(path_in_dir("_deps"), relative_path) +-def _dep_source_path(relative_path): +- return os.path.join(_path_in_dir("deps"), relative_path) - - def read(fname): +-def _dep_build_path(relative_path): +- return os.path.join(_path_in_dir("_deps/build"), relative_path) +- + def _read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() --jq_lib_tarball_path = dependency_path("jq-lib-1.6.tar.gz") --jq_lib_dir = dependency_path("jq-1.6") +-jq_lib_tarball_path = _dep_source_path("jq-1.6.tar.gz") +-jq_lib_dir = _dep_build_path("jq-1.6") - -oniguruma_version = "6.9.4" --oniguruma_lib_tarball_path = dependency_path("onig-{}.tar.gz".format(oniguruma_version)) --oniguruma_lib_build_dir = dependency_path("onig-{}".format(oniguruma_version)) --oniguruma_lib_install_dir = dependency_path("onig-install-{}".format(oniguruma_version)) +-oniguruma_lib_tarball_path = _dep_source_path("onig-{}.tar.gz".format(oniguruma_version)) +-oniguruma_lib_build_dir = _dep_build_path("onig-{}".format(oniguruma_version)) +-oniguruma_lib_install_dir = _dep_build_path("onig-install-{}".format(oniguruma_version)) - -class jq_build_ext(build_ext): - def run(self): -- if not os.path.exists(dependency_path(".")): -- os.makedirs(dependency_path(".")) +- if not os.path.exists(_dep_build_path(".")): +- os.makedirs(_dep_build_path(".")) - self._build_oniguruma() - self._build_libjq() - build_ext.run(self) - - def _build_oniguruma(self): - self._build_lib( -- source_url="https://github.com/kkos/oniguruma/releases/download/v{0}/onig-{0}.tar.gz".format(oniguruma_version), - tarball_path=oniguruma_lib_tarball_path, - lib_dir=oniguruma_lib_build_dir, - commands=[ @@ -75,7 +58,6 @@ index 663792c..3ebcabe 100644 - - def _build_libjq(self): - self._build_lib( -- source_url="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz", - tarball_path=jq_lib_tarball_path, - lib_dir=jq_lib_dir, - commands=[ @@ -83,9 +65,8 @@ index 663792c..3ebcabe 100644 - ["make"], - ]) - -- def _build_lib(self, source_url, tarball_path, lib_dir, commands): -- self._download_tarball( -- source_url=source_url, +- def _build_lib(self, tarball_path, lib_dir, commands): +- self._extract_tarball( - tarball_path=tarball_path, - lib_dir=lib_dir, - ) @@ -101,16 +82,10 @@ index 663792c..3ebcabe 100644 - for command in commands: - run_command(command) - -- def _download_tarball(self, source_url, tarball_path, lib_dir): -- if os.path.exists(tarball_path): -- os.unlink(tarball_path) -- print("Downloading {}".format(source_url)) -- urlretrieve(source_url, tarball_path) -- print("Downloaded {}".format(source_url)) -- +- def _extract_tarball(self, tarball_path, lib_dir): - if os.path.exists(lib_dir): - shutil.rmtree(lib_dir) -- tarfile.open(tarball_path, "r:gz").extractall(dependency_path(".")) +- tarfile.open(tarball_path, "r:gz").extractall(_dep_build_path(".")) - - jq_extension = Extension( @@ -126,19 +101,11 @@ index 663792c..3ebcabe 100644 ) setup( -@@ -120,7 +26,6 @@ setup( - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', +@@ -104,7 +25,6 @@ def _extract_tarball(self, tarball_path, lib_dir): + python_requires='>=3.5', license='BSD 2-Clause', ext_modules = [jq_extension], - cmdclass={"build_ext": jq_build_ext}, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', -@@ -137,4 +42,3 @@ setup( - 'Programming Language :: Python :: 3.9', - ], - ) -- --- -2.29.3 - From 01001f04dab445dd1efcc55ad4ad4e6a7d2187d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 8 Nov 2022 01:22:06 +0100 Subject: [PATCH 3/4] changedetection-io: 0.39.20.4 -> 0.39.21.1 --- pkgs/servers/web-apps/changedetection-io/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/servers/web-apps/changedetection-io/default.nix b/pkgs/servers/web-apps/changedetection-io/default.nix index cd53cf147445..888ccf675e96 100644 --- a/pkgs/servers/web-apps/changedetection-io/default.nix +++ b/pkgs/servers/web-apps/changedetection-io/default.nix @@ -31,21 +31,21 @@ let in py.pkgs.buildPythonApplication rec { pname = "changedetection-io"; - version = "0.39.20.4"; + version = "0.39.21.1"; format = "setuptools"; src = fetchFromGitHub { owner = "dgtlmoon"; repo = "changedetection.io"; rev = version; - sha256 = "sha256-XhCByQbGWAwWe71jsitpYJnQ2xRIdmhc9mY6Smxmp3w="; + sha256 = "sha256-cX2HwlsWOJ34msEnPP38jq+kzSxOM/spe0Ja2lZ/Q7w="; }; postPatch = '' substituteInPlace requirements.txt \ --replace "bs4" "beautifulsoup4" \ - --replace "cryptography ~= 3.4" "cryptography" \ - --replace "selenium ~= 4.1.0" "selenium" + --replace "cryptography~=3.4" "cryptography" \ + --replace "selenium~=4.1.0" "selenium" ''; propagatedBuildInputs = with py.pkgs; [ @@ -58,6 +58,8 @@ py.pkgs.buildPythonApplication rec { feedgen flask-login flask-restful + jinja2 + jinja2-time pytz brotli requests From 677d6f1623b1054ce9832c55c5be3a9b049bc086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 8 Nov 2022 01:22:13 +0100 Subject: [PATCH 4/4] nixos/changedetection-io: hide referer by default --- nixos/modules/services/web-apps/changedetection-io.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/changedetection-io.nix b/nixos/modules/services/web-apps/changedetection-io.nix index ace4cf1eabc9..fc00aee43516 100644 --- a/nixos/modules/services/web-apps/changedetection-io.nix +++ b/nixos/modules/services/web-apps/changedetection-io.nix @@ -138,7 +138,8 @@ in StateDirectory = mkIf defaultStateDir "changedetection-io"; StateDirectoryMode = mkIf defaultStateDir "0750"; WorkingDirectory = cfg.datastorePath; - Environment = lib.optional (cfg.baseURL != null) "BASE_URL=${cfg.baseURL}" + Environment = [ "HIDE_REFERER=true" ] + ++ lib.optional (cfg.baseURL != null) "BASE_URL=${cfg.baseURL}" ++ lib.optional cfg.behindProxy "USE_X_SETTINGS=1" ++ lib.optional cfg.webDriverSupport "WEBDRIVER_URL=http://127.0.0.1:${toString cfg.chromePort}/wd/hub" ++ lib.optional cfg.playwrightSupport "PLAYWRIGHT_DRIVER_URL=ws://127.0.0.1:${toString cfg.chromePort}/?stealth=1&--disable-web-security=true";