From d6e6a6c629db3db52f23c43fd4cf4363253ea77f Mon Sep 17 00:00:00 2001 From: Oliver Berger Date: Tue, 27 Oct 2026 17:12:15 +0100 Subject: [PATCH] fix: replace mimetypes.patch for wrapped knownfiles layout CPython 3.14.9+ (and 3.11.18+/3.12.16+/3.13.18+/3.15.x) wrap the `knownfiles` list in Lib/mimetypes.py in an `if sys.platform == "win32"` branch, so nixpkgs' mimetypes.patch (targeting the old flat layout) fails to apply: applying patch .../mimetypes.patch patching file Lib/mimetypes.py Hunk #1 FAILED at 40. This breaks building every 3.14.9+ release, i.e. the current `latest."3.14"` alias (3.14.10), with any nixpkgs rev. Add a replacement patch matching the wrapped layout (still emitting the @mime-types@ marker that nixpkgs substitutes with --replace-fail) and apply it via the existing replacePatch override machinery for all affected versions. --- flake.nix | 8 ++++++++ patches/mimetypes-wrapped.patch | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 patches/mimetypes-wrapped.patch diff --git a/flake.nix b/flake.nix index bcf7099..eb55303 100644 --- a/flake.nix +++ b/flake.nix @@ -299,6 +299,14 @@ condition = version: versionInBetween version "3.15" "3.14.5"; override = filterOutPatch "hacl-static-ldeps-for-static-modules.patch"; } + { + # CPython 3.11.18+/3.12.16+/3.13.18+/3.14.9+/3.15.x wrap the + # `knownfiles` list in an `if sys.platform == "win32"` branch, so + # nixpkgs' mimetypes.patch (flat-list layout) fails to apply. + # Use a replacement patch matching the wrapped layout. + condition = version: versionInBetween version "3.16" "3.11.18"; + override = replacePatch "mimetypes.patch" ./patches/mimetypes-wrapped.patch; + } ]; callPackage = pkgs.newScope { inherit python; diff --git a/patches/mimetypes-wrapped.patch b/patches/mimetypes-wrapped.patch new file mode 100644 index 0000000..2802974 --- /dev/null +++ b/patches/mimetypes-wrapped.patch @@ -0,0 +1,19 @@ +diff --git i/Lib/mimetypes.py w/Lib/mimetypes.py +index f3343c8..ab5b886 100644 +--- i/Lib/mimetypes.py ++++ w/Lib/mimetypes.py +@@ -51,12 +51,4 @@ + else: + knownfiles = [ +- "/etc/mime.types", +- "/etc/httpd/mime.types", # Mac OS X +- "/etc/httpd/conf/mime.types", # Apache +- "/etc/apache/mime.types", # Apache 1 +- "/etc/apache2/mime.types", # Apache 2 +- "/usr/local/etc/httpd/conf/mime.types", +- "/usr/local/lib/netscape/mime.types", +- "/usr/local/etc/httpd/conf/mime.types", # Apache 1.2 +- "/usr/local/etc/mime.types", # Apache 1.3 +- ] ++ "@mime-types@", ++ ]