From c502237b421d34f2c41d311b4167a948bf26598f Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sat, 11 Jul 2026 22:43:45 +0800 Subject: [PATCH 1/2] buildPythonPackage: implement disabled with meta.problems.unsupportedPython Implement the `disabled` argument behaviour with meta.problems.unsupportedPython instead of the ugly and buggy `lib.extendDerivation`. For compatibility purposes, keep the `passthru.disabled` attribute's overridable with overrideAttrs while giving higher precedence to direct specification/overriding of `meta.problems.unsupportedPython`, making this commit safe to backport. --- doc/languages-frameworks/python.section.md | 37 +++++++++++++++++- .../python/mk-python-derivation.nix | 38 ++++++++++--------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 0a69d93bb7456..e078e8dce9e8b 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -163,8 +163,41 @@ following are specific to `buildPythonPackage`: * `catchConflicts ? true`: If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`. -* `disabled ? false`: If `true`, package is not built for the particular Python - interpreter version. +* `disabled ? false`: + If set to `true` for a particular Python interpreter version or implementation, the package is marked with `meta.problems.unsupportedPython`, and will throw an error message complaining the Python interpreter being unsupported during package instantiation. + + ```nix + { + lib, + pythonAtLeast, + buildPythonPackage, + fetchFromGitHub, + setuptools, + }: + buildPythonPackage (finalAttrs: { + pname = "coconut"; + version = "3.1.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "evhub"; + repo = "coconut"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Vd6ZY3PlbPOy63/0/0YJ1U2PpsVdctOoInyKftj//cM="; + }; + + disabled = pythonAtLeast "3.13"; + + build-system = [ + setuptools + ]; + + meta = { + homepage = "http://coconut-lang.org/"; + }; + }) + ``` + * `dontWrapPythonPrograms ? false`: Skip wrapping of Python programs. * `permitUserSite ? false`: Skip setting the `PYTHONNOUSERSITE` environment variable in wrapped programs. diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index bc44a7de71789..a697c82d71a08 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -411,12 +411,14 @@ lib.extendMkDerivation { passthru = { inherit - disabled pyproject build-system dependencies optional-dependencies ; + + disabled = meta ? problems.unsupportedPython || disabled; + updateScript = nix-update-script { }; # __stdenvPythonCompat[Pos] attributes are here for overrideStdenvCompat in `python-packages-base.nix` to work. # They are internal and subject to changes. @@ -432,7 +434,22 @@ lib.extendMkDerivation { platforms = python.meta.platforms; isBuildPythonPackage = python.meta.platforms; } - // meta; + // meta + // { + problems = + let + disabled' = meta ? problems.unsupportedPython || finalAttrs.disabled; + in + meta.problems or { } + // { + ${if disabled' then "unsupportedPython" else null} = meta.problems.unsupportedPython or { } // { + kind = "broken"; + message = + meta.problems.unsupportedPython.message + or "${removePrefix namePrefix finalAttrs.name} not supported for interpreter ${python.executable}"; + }; + }; + }; } // optionalAttrs (attrs ? checkPhase) { # If given use the specified checkPhase, otherwise use the setup hook. @@ -468,20 +485,5 @@ lib.extendMkDerivation { # This derivation transformation function must be independent to `attrs` # for fixed-point arguments support in the future. - transformDrv = - let - # Workaround to make the `lib.extendDerivation`-based disabled functionality - # respect `.overrideAttrs` - # It doesn't cover `..overrideAttrs`. - disablePythonPackage = - drv: - extendDerivation ( - drv.disabled - -> throw "${removePrefix namePrefix drv.name} not supported for interpreter ${python.executable}" - ) { } drv - // { - overrideAttrs = fdrv: disablePythonPackage (drv.overrideAttrs fdrv); - }; - in - drv: disablePythonPackage (toPythonModule drv); + transformDrv = toPythonModule; } From 8d4947042181099c7f4867fd94101fe40523726c Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sat, 11 Jul 2026 22:49:25 +0800 Subject: [PATCH 2/2] buildPythonPackage: make passthru.disabled reference `finalAttrs ? meta.problems.unsupportedPython` --- doc/languages-frameworks/python.section.md | 44 +++++++++++++++++++ doc/release-notes/rl-2611.section.md | 6 +++ .../python/mk-python-derivation.nix | 4 +- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index e078e8dce9e8b..523f2bb063fe5 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -198,6 +198,50 @@ following are specific to `buildPythonPackage`: }) ``` + One can also choose to mark a package with `meta.problems.unsupportedPython` providing a custom `message` and optional `urls`: + + ```nix + { + lib, + python, + pythonAtLeast, + buildPythonPackage, + fetchFromGitHub, + setuptools, + }: + buildPythonPackage (finalAttrs: { + pname = "coconut"; + version = "3.1.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "evhub"; + repo = "coconut"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Vd6ZY3PlbPOy63/0/0YJ1U2PpsVdctOoInyKftj//cM="; + }; + + build-system = [ + setuptools + ]; + + meta = { + homepage = "http://coconut-lang.org/"; + problems.unsupportedPython = lib.optionalAttrs (pythonAtLeast "3.13") { + message = lib.removePrefix (python.libPrefix + "-") finalAttrs.name + " requires Python <3.13"; + urls = [ + "https://github.com/evhub/coconut/issues/873" + ]; + }; + }; + }) + ``` + + ::: {.note} + Referencing `.disabled` or `finalAtts.disabled` for Python packages are deprecated. + Use ` ? meta.problems.unsupportedPython` instead (the same goes with `finalAttrs`). + ::: + * `dontWrapPythonPrograms ? false`: Skip wrapping of Python programs. * `permitUserSite ? false`: Skip setting the `PYTHONNOUSERSITE` environment variable in wrapped programs. diff --git a/doc/release-notes/rl-2611.section.md b/doc/release-notes/rl-2611.section.md index ce3330d0b967a..610b3b0f8e6f7 100644 --- a/doc/release-notes/rl-2611.section.md +++ b/doc/release-notes/rl-2611.section.md @@ -107,6 +107,12 @@ - `nim1` and respective aliases have been removed due to entering EOL; please migrate to `nim` or `nim-unwrapped` (nim 2). - `nim-2_0` & `nim-2_2` and respective aliases have been removed; please migrate to `nim` or `nim-unwrapped` (nim 2.2.10). +- `buildPythonPackage` and `buildPythonApplication` now uses `meta.problems.unsupportedPython` to mark Python packages with unsupported Python interpreters. + - The `disabled` argument automatically converts to `meta.problems.unsupportedPython` with the default message. + - Overriding the `passthru.disabled` attribute no longer affects such marks. + - ` ? meta.problems.unsupportedPython` is now the canonical way to identify if the package uses an incompatible Python interpreter. + The `passthru.disabled` attribute is deprecated and will be removed in future releases. + - `vimacs` has been removed, as it has not been maintained in 10 years and was built for an old version of vim (6.0). ## Other Notable Changes {#sec-nixpkgs-release-26.11-notable-changes} diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index a697c82d71a08..76ade5f96d930 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -417,7 +417,7 @@ lib.extendMkDerivation { optional-dependencies ; - disabled = meta ? problems.unsupportedPython || disabled; + disabled = finalAttrs ? meta.problems.unsupportedPython; updateScript = nix-update-script { }; # __stdenvPythonCompat[Pos] attributes are here for overrideStdenvCompat in `python-packages-base.nix` to work. @@ -438,7 +438,7 @@ lib.extendMkDerivation { // { problems = let - disabled' = meta ? problems.unsupportedPython || finalAttrs.disabled; + disabled' = meta ? problems.unsupportedPython || disabled; in meta.problems or { } // {