Package setup hooks and .override

I would like to add some lines of bash to the postInstall hook in a package using .override.
Should I append them to the existing packages hook script?

somePackage.override {
  postInstall = somePackage.postInstall + ''
    foobar
  '';
};

Or can I perhaps call mkDerivation on the original package first?

1 Like

.override is for changing the function definition (the arguments in the curly braces at the top of the package definition). You’re looking for .overrideAttrs, which will let you override parts of the mkDerivation call.

I’d do something like this:

somePackage.overrideAttrs ({ postInstall ? "", ... }: {
  postInstall = postInstall + ''
    foobar
  '';
})
4 Likes