Is there a function or helper for patching derivations with scripts?

Is there some helper that takes one derivation, and a script, and returns a derivation that just patches the first derivation? Something with an API like this:

patchWithScript {
  input = pkgs.hello;
  script = ''
    rm bin/hello
  '';
}

Not at the moment no, this is tracked in this issue:

I made a few helpers like this in my config, I linked them all in a comment on that issue :slight_smile:

1 Like

Not exactly what you wanted, but there’s the underutilized applyPatches function. It’s main usecase is just patching source files based off of .patch files. It won’t really work for your use-case, but thought I’d just put it here.