I can't override a python package


I am trying to install an old version of numpy (specifically 1.19.5) because I am dealing with a piece of code who requires python36. But I get this error:

$ nix develop
error: numpy-1.21.2 not supported for interpreter python3.6
(use '--show-trace' to show detailed location information)

It looks like it does not care about the attr override, wondering what I am doing wrong

  description = "A very basic flake";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs?rev=139cadbf1ce28cb6f246a589b9cef49968e76676";
    flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
        pkgs = import nixpkgs { inherit system; };

        python =
            packageOverrides = self: super: {
              numpy = super.numpy.overridePythonAttrs (old: rec {
                version = "0.19.5";
                src = super.fetchPypi {
                  pname = "numpy";
                  inherit version;
                  hash = "sha256-JQn+rtpy/OA2deLszSKEuxyttqBzcAil50H+JDHUdCD=";
          pkgs.python36.override { inherit packageOverrides; self = python; };

        devenv = python.withPackages (ps: [
        devShell = pkgs.mkShell {
          packages = [

The exception is thrown from pkgs/development/interpreters/python/mk-python-derivation.nix:L104.
Looking at how makeOverridablePythonPackage is defined in pkgs/top-level/python-packages.nix, I think that the problem is that in order to apply the override, we first have to calculate the original attrs that were passed, and then we’ll merge in the ones passed to overridePythonAttrs.

But since an exception is thrown in the function that creates the original derivation, we never get to apply the new attrs, because evaluation crashes on the exception while we’re still calculating the old attrs.

I think that the way in which this is written, basically means that you cannot override attrs when the original derivation already led to an exception.

Your best bet is probably to check out a copy of nixpkgs at that revision, remove the throw statement, and use that version of nixpkgs as input for your flake (inputs.nixpkgs.url = "path:/<...>/nixpkgs";).

Thnks @R-VdP ! There is a lot to unwrap in your response but I think I get it.
I noticed that nixpgks in the version I currently checked out contains this file that install an old version of numpy

I am wondering how I can access it. I tried with ps.numpy-116 and similar but it looks incorrect. Do you happen to know?

I got it to build in nix repl like this (let it run for a couple of minutes but did not wait for it to finish)

nix-repl> :lf github:NixOS/nixpkgs/139cadbf1ce28cb6f246a589b9cef49968e76676 
Added 15 variables.

nix-repl> numpy = import "${outPath}/pkgs/development/python-modules/numpy/1.16.nix"     

nix-repl> pkg = legacyPackages.x86_64-linux.python36Packages.callPackage numpy {}

nix-repl> :b pkg

So in your flake that would be

pkgs.python36Packages.callPackage "${nixpkgs}/pkgs/development/python-modules/numpy/1.16.nix" {}