I tried to do the same thing without success as of now.
My exact nix snippet is
{ pkgs ? import <nixpkgs> { } }:
let
py = let
packageOverrides = self: super: {
azure-identity = super.azure-identity.overridePythonAttrs (oldattrs: {
disabled = false;
version = "newVersion";
});};
in (pkgs.python3.override { inherit packageOverrides; }).pkgs;
in py.azure-identity
And I have this error
$ nix-build x.nix --show-trace
error: while evaluating anonymous function at pwd/x.nix:1:1, called from undefined position:
while evaluating the attribute 'azure-identity' at pwd/x.nix:6:7:
while evaluating the attribute 'azure-identity.overridePythonAttrs' at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/top-level/python-packages.nix:574:3:
while evaluating 'callPackageWith' at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/lib/customisation.nix:117:35, called from /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/top-level/python-packages.nix:574:20:
while evaluating 'makeOverridable' at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/lib/customisation.nix:67:24, called from /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/lib/customisation.nix:121:8:
while evaluating anonymous function at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/development/python-modules/azure-identity/default.nix:1:1, called from /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/lib/customisation.nix:69:16:
while evaluating 'makeOverridablePythonPackage' at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/top-level/python-packages.nix:28:37, called from /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/development/python-modules/azure-identity/default.nix:18:1:
while evaluating 'makeOverridable' at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/lib/customisation.nix:67:24, called from /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/top-level/python-packages.nix:30:12:
while evaluating anonymous function at /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:30:1, called from /nix/store/q0v3m59iid3h0x8hrps2d8f5s5jk6m8r-nixpkgs-21.03pre262503.51894963cbd/nixpkgs/lib/customisation.nix:69:16:
azure-identity-1.5.0 not supported for interpreter python3.8
A side-question is why this package is specifically disabled for python3.8 which is now default python3 in nixpkgs. This is strange as it seems to be supported upstream.
Your observation is correct. The throw is evaluated before any override can be applied, because overrides can only be applied if the initial function call (buildPythonPackage in this case) returns a value and does not throw.
There is also an open GitHub issue for this problem: