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:
let
pkgs = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/1b9e74a8ded639e1d4da83a2c8656458cb048cd9.tar.gz) {};
in
pkgs.mkShell {
buildInputs = [
pkgs.nodejs-16_x
(pkgs.yarn.overrideAttrs (oldAttrs: {
buildInputs = [pkgs.nodejs-16_x];
}))
pkgs.bash
];
}
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?