NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

Multiple `python2Packages` fail the evaluation due to `dependencies` in the environment. #340183

Open trofi opened 2 months ago

trofi commented 2 months ago

Affected packages are at least:

Changes like https://github.com/NixOS/nixpkgs/pull/335112 broke the evaluation for pythonPackages. Example failure:

$ nix-instantiate -A pypy27Packages.incremental
error:
       … while evaluating the attribute 'drvPath'
         at /tmp/z/nixpkgs/lib/customisation.nix:365:7:
          364|     in commonAttrs // {
          365|       drvPath = assert condition; drv.drvPath;
             |       ^
          366|       outPath = assert condition; drv.outPath;

       … while evaluating the attribute 'drvPath'
         at /tmp/z/nixpkgs/lib/customisation.nix:365:7:
          364|     in commonAttrs // {
          365|       drvPath = assert condition; drv.drvPath;
             |       ^
          366|       outPath = assert condition; drv.outPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: cannot coerce a set to a string: { scripts = «thunk»; }

This is a "syntactic" error of a non-catchable exception.

Note that this specific package used to fail with a catchable excaption:

$ nix-instantiate -A pypy27Packages.incremental
error:
       … while evaluating the attribute 'drvPath'
         at /tmp/z/nixpkgs/lib/customisation.nix:365:7:
          364|     in commonAttrs // {
          365|       drvPath = assert condition; drv.drvPath;
             |       ^
          366|       outPath = assert condition; drv.outPath;

       … while evaluating the attribute 'drvPath'
         at /tmp/z/nixpkgs/lib/customisation.nix:365:7:
          364|     in commonAttrs // {
          365|       drvPath = assert condition; drv.drvPath;
             |       ^
          366|       outPath = assert condition; drv.outPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: click-8.1.7 not supported for interpreter pypy

Expected behavior

The exception should be catchable and report unsupported interpreter.

Additional context

My naive attempts to move attrsets out of the environment were rejected in:

And the suggestion was: https://github.com/NixOS/nixpkgs/pull/338559#issuecomment-2323064175

""" You can fix buildPythonPackage instead.

You'd have to replicate https://github.com/NixOS/nixpkgs/commit/b9138b7c072f5 in pkgs/development/interpreters/python/python2/mk-python-derivation.nix. """

I don't think I can pull it out without investing some time to understand how python wraps and filters attributes just to restore the evaluation of packages.

Notify maintainers

Maybe python team: @mweinelt @natsukium

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.6, NixOS, 24.11 (Vicuna), 24.11.20240906.0e0665d`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.4`
 - channels(root): `""`
 - channels(slyfox): `""`
 - nixpkgs: `/run/current-system/sw/share/nixos-flakes/inputs/nixpkgs`

Add a :+1: reaction to issues you find important.

mweinelt commented 2 months ago

As long as we don't recurse into these package sets we cannot guarantee things won't break all the time. And for that we'd need someone to care about pypy a lot.

trofi commented 2 months ago

FWIW I think pythonPackages is in roughly the same boat:

$ NIXPKGS_ALLOW_INSECURE=1 nix-instantiate -A pythonPackages.incremental
error:
       … while evaluating the attribute 'drvPath'
         at /home/slyfox/dev/git/nixpkgs-master/lib/customisation.nix:365:7:
          364|     in commonAttrs // {
          365|       drvPath = assert condition; drv.drvPath;
             |       ^
          366|       outPath = assert condition; drv.outPath;

       … while evaluating the attribute 'drvPath'
         at /home/slyfox/dev/git/nixpkgs-master/lib/customisation.nix:365:7:
          364|     in commonAttrs // {
          365|       drvPath = assert condition; drv.drvPath;
             |       ^
          366|       outPath = assert condition; drv.outPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: cannot coerce a set to a string: { scripts = «thunk»; }
dotlambda commented 2 months ago

Quoting the solution from https://github.com/NixOS/nixpkgs/pull/338559#issuecomment-2323064175:

You can fix buildPythonPackage instead.

You'd have to replicate b9138b7c072f5 in pkgs/development/interpreters/python/python2/mk-python-derivation.nix.

Oops, didn't see that this was included in the OP.

trofi commented 1 month ago

A few more fresh eval regressions with the same cause: