If comment the Keras part, it complains about other overlays in the python_overalys file. The only way is to comment all the file, so it works. It seems to me that python_overlays.nix is being evaluated directly by nix-env -qa command, not from inside the overlays.nix.
Your overlay actually seems to work for me just fine when run against the current nixpkgs-unstable channel. I’m not installing it globally but testing against a file import <nixpkgs> { overlays = [(import ./overlay.nix)]; }, but that shouldn’t make a difference.
That said, according to the documentation you need to pass the self parameter to the override as pointing back to the python in question. I suspect this is used to ensure your override is exposed to any other package that depends on what you’re overriding. This change looks like:
This can be cleaned up a bit to avoid duplication:
self: super:
let overridePython = oldPython:
let python = oldPython.override {
packageOverrides = import ./python_overlays.nix;
self = python;
}; in python;
in
{
python3 = overridePython super.python3;
python37 = overridePython super.python37;
python38 = overridePython super.python38;
}
Also the same documentation says you should be using overridePythonAttrs. Using overrideAttrs like you are actually means you’re not modifying the generated name attribute. You should be able to just replace your usage of overrideAttrs with .overridePythonAttrs directly.
Thanks @lilyball. The overlays were working OK here too with nixos-unstable. I applied the modifications you suggested (I tried both version) but I’m having the problem with nix-env -qa yet, see:
$ nix-env -qa torch
error: attribute 'Keras' missing, at /home/thiago/.config/nixpkgs/overlays/python_overlays.nix:10:11
I have other overlays (neovim and zettlr), they are not declared inside overlays.nix or python_overlays.nix. To test I removed both overlays and the same error happen.
This is because of the use of overrideAttrs instead of overridePythonAttrs. buildPythonPackage calculates the name attribute directly instead of letting mkDerivation do it; overridePythonAttrs will ensure it calculates name using your new version attribute.
It’s a shame --show-trace apparently did nothing. You could do nix-env --debug -qa torch but that output is likely to not actually be particularly helpful. Do you have any packageOverrides declared that could be interfering? Or any unusual channels installed?
I suspect the issue is the python_overlays.nix file in $HOME/.config/nixpkgs/overlays, which is not a nixpkgs overlay, but a python.packageOverrides overlay.
All files in the overlays folder are read as nixpkgs overlays and therefore when the file python_overlays.nix is read as a nixpkgs overlay, python-self and python-super actually are self and super from nixpkgs, not python. In this case super.Keras (python-super.Keras) does not exist and raises the attribute 'Keras' missing error.
The error does not affect all nix commands, as most of them don’t evaluate the whole nixpkgs set, but only the needed values.
You should try to move the python_overlays.nix file out of the overlays folder or combine the two files into one:
The simple solution is to just nest them in a subfolder, so you have ~/.config/nixpkgs/overlays/python-overlay/ where your actual overlay is default.nix in this folder.