From b88ce3f36742c2a6ff09ca0a48c074259394c42c Mon Sep 17 00:00:00 2001 From: nyanotech Date: Fri, 16 Jun 2023 01:12:12 -0700 Subject: [PATCH 1/2] python3Packages.pem: Init at 21.2.0 --- .../python-modules/pem/default.nix | 46 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 48 insertions(+) create mode 100644 pkgs/development/python-modules/pem/default.nix diff --git a/pkgs/development/python-modules/pem/default.nix b/pkgs/development/python-modules/pem/default.nix new file mode 100644 index 000000000000..3ef5b7ffc75c --- /dev/null +++ b/pkgs/development/python-modules/pem/default.nix @@ -0,0 +1,46 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitHub +, pytestCheckHook +, certifi +, cryptography +, pretend +, pyopenssl +, twisted +}: + +buildPythonPackage rec { + pname = "pem"; + version = "21.2.0"; + + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "hynek"; + repo = pname; + rev = version; + hash = "sha256-mftLdgtgb5J4zwsb1F/4v4K7XTy4VSZBMy3zPV2f1uA="; + }; + + nativeCheckInputs = [ + certifi + cryptography + pretend + pyopenssl + pytestCheckHook + twisted + twisted.optional-dependencies.tls + ]; + + pythonImportsCheck = [ + "pem" + ]; + + meta = with lib; { + homepage = "https://pem.readthedocs.io/"; + description = "Easy PEM file parsing in Python."; + license = licenses.mit; + maintainers = with maintainers; [ nyanotech ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 1dfd4e32504c..d358cdd4aad0 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7476,6 +7476,8 @@ self: super: with self; { inherit (pkgs) glibcLocales git; }; + pem = callPackage ../development/python-modules/pem { }; + pendulum = callPackage ../development/python-modules/pendulum { }; pep440 = callPackage ../development/python-modules/pep440 { }; From aefce34bc550d1b5405cc96eb1850f8081ebcb46 Mon Sep 17 00:00:00 2001 From: nyanotech Date: Fri, 16 Jun 2023 03:18:39 -0700 Subject: [PATCH 2/2] syncplay: fix tls support in client Adds "pem", which is a new dependency added in the last release from upstream. Nixos patches certifi to return the system ca bundle, which includes openssl-format "trusted certificate"s, which pyopenssl seems to choke on when syncplay tries to load them. Therefore, we add a patch that skips those "trusted certificates". --- pkgs/applications/networking/syncplay/default.nix | 4 +++- .../networking/syncplay/trusted_certificates.patch | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 pkgs/applications/networking/syncplay/trusted_certificates.patch diff --git a/pkgs/applications/networking/syncplay/default.nix b/pkgs/applications/networking/syncplay/default.nix index 306822d74e7b..36b6b5c14339 100644 --- a/pkgs/applications/networking/syncplay/default.nix +++ b/pkgs/applications/networking/syncplay/default.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , buildPythonApplication , fetchpatch +, pem , pyside6 , twisted , certifi @@ -30,10 +31,11 @@ buildPythonApplication rec { url = "https://github.com/Syncplay/syncplay/commit/b62b038cdf58c54205987dfc52ebf228505ad03b.patch"; hash = "sha256-pSP33Qn1I+nJBW8T1E1tSJKRh5OnZMRsbU+jr5z4u7c="; }) + ./trusted_certificates.patch ]; buildInputs = lib.optionals enableGUI [ (if stdenv.isLinux then qt6.qtwayland else qt6.qtbase) ]; - propagatedBuildInputs = [ twisted certifi ] + propagatedBuildInputs = [ certifi pem twisted ] ++ twisted.optional-dependencies.tls ++ lib.optional enableGUI pyside6 ++ lib.optional (stdenv.isDarwin && enableGUI) appnope; diff --git a/pkgs/applications/networking/syncplay/trusted_certificates.patch b/pkgs/applications/networking/syncplay/trusted_certificates.patch new file mode 100644 index 000000000000..4cf613080024 --- /dev/null +++ b/pkgs/applications/networking/syncplay/trusted_certificates.patch @@ -0,0 +1,12 @@ +diff --git a/syncplay/client.py b/syncplay/client.py +index b7cb245..be72d94 100755 +--- a/syncplay/client.py ++++ b/syncplay/client.py +@@ -848,6 +848,7 @@ class SyncplayClient(object): + self._endpoint = HostnameEndpoint(reactor, host, port) + try: + certs = pem.parse_file(SSL_CERT_FILE) ++ certs = [cert for cert in certs if type(cert) is pem.Certificate] + trustRoot = trustRootFromCertificates([Certificate.loadPEM(str(cert)) for cert in certs]) + self.protocolFactory.options = optionsForClientTLS(hostname=host, trustRoot=trustRoot) + self._clientSupportsTLS = True