Something in my system has a python2 dependency, and I don't know how to find it

I made a change in my NixOS configuration, I reverted that change, because it got me:

[nixos@nixos:~/nixcfg]$ nix build './#nixosConfigurations.megamind.config.system.build.toplevel'
error: Package ‘python-2.7.18.6’ in /nix/store/s02jdlqmv902b0y19jy4kybl86ylwvvy-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:330 is marked as insecure, refusing to evaluate.

[...]

(full taceback)

Now, after reverting, I’m still seem to be stuck with that obsolete python2 dependency that wasn’t there before. I cannot figure out where it comes from and how to get rid of it. Running why-depdends doesn’t really tell me much:

[nixos@nixos:~/nixcfg]$ nix why-depends --all './#nixosConfigurations.megamind.config.system.build.toplevel' /nix/store/n0qfrr5i95p0r5iqdb70dp3i73mzfw7n-python-2.7.18.6
/nix/store/sm65nxbpa3x00jgdwk6m4rwcrrl45grg-nixos-system-nixos-23.05.20231021.5550a85
├───/nix/store/v1glf84b5rfaw5a4i00fk47dwrcnkgf2-system-path
│   └───/nix/store/n0qfrr5i95p0r5iqdb70dp3i73mzfw7n-python-2.7.18.6
└───/nix/store/pcki391hz1kwmv9wwm5c511a00dnj7pq-etc
    ├───/nix/store/v1glf84b5rfaw5a4i00fk47dwrcnkgf2-system-path
    ├───/nix/store/ydpmic5a6fn7r8qij2rha6dkb6bp5sj7-dbus-1
    │   └───/nix/store/v1glf84b5rfaw5a4i00fk47dwrcnkgf2-system-path
    ├───/nix/store/99ja2bj3q1vvwh1xryxjqyzw1j6bvna4-system-units
    │   ├───/nix/store/ga9n5z66drs6xwfcfwjb7fac50w9gl8l-unit-systemd-fsck-.service
    │   │   └───/nix/store/v1glf84b5rfaw5a4i00fk47dwrcnkgf2-system-path
    │   └───/nix/store/l08qgxxgh6jfr8s3kzsrawrrrzhx3snh-unit-dbus.service
    │       └───/nix/store/rmy8qgx8b7l7zigrvsfzl397c0q1ll22-X-Restart-Triggers
    │           └───/nix/store/ydpmic5a6fn7r8qij2rha6dkb6bp5sj7-dbus-1
    └───/nix/store/66rbbdfzjvgws6kqwkl6p0nivdvh8s1g-user-units
        └───/nix/store/3jz5gw9qgpy7sl1sda2y8cpmsl3f4djp-unit-dbus.service
            └───/nix/store/rmy8qgx8b7l7zigrvsfzl397c0q1ll22-X-Restart-Triggers

Any ideas on how to debug this?

This is always a bit of a PITA when it’s not obvious from why-depends, this suggests python2 is added directly to environment.systemPackages or consorts (a python on your $PATH probably points to python 2, in fact), which obviously you’ve not done deliberately, so it’s probably part of some module or something.

Luckily python is an interpreter, maybe you can find the culprit with ps aux | grep python?

3 Likes

Thanks, that got me on the right track. One of my inputs had set follows to an older version of nixpkgs and was probably thinking pkgs.python was Python 3, when in fact it was Python 2. The change and revert was just coincidental, it was re-locking that introduced the problem, which I hadn’t reverted.

1 Like