What is the type of the argument to `overrideAttrs`

I am looking at the documentation for overrideAttrs.

The example in the docs show overrideAttrs being called with a function that takes two arguments and returns an attribute set. (Let’s ignore the fact that the function is curried; it is just easier to talk about a function that takes two arguments).

helloWithDebug = pkgs.hello.overrideAttrs (finalAttrs: previousAttrs: {
  separateDebugInfo = true;

However, I recently wrote a working nix-shell in which I called overrideAttrs with a function that only takes one argument:

  pkgs = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/1b9e74a8ded639e1d4da83a2c8656458cb048cd9.tar.gz) {};
  pkgs.mkShell {
    buildInputs = [

      (pkgs.yarn.overrideAttrs (oldAttrs: {
        buildInputs = [pkgs.nodejs-16_x];


How is it possible that these two things are both correct? Is overrideAttrs able to dispatch based on whether the function takes one argument or two?

1 Like

Looks like I answered my own question. From the docs: If only a one-argument function is written, the argument has the meaning of previousAttrs..