There’s a few ways I know of to programmatically modify a derivation. There’s
lib.overrideDerivation which works on a fairly low-level (and doesn’t compose), and there’s also
drv.overrideAttrs which is preferred.
Is it possible to override the result of importing a
.drv file? I can import it and pass the result to
true as well. But neither
drv.overrideAttrs works on the result of importing a
.drv file. It looks like a sample derivation’s attrNames is
[ "all" "drvPath" "name" "out" "outPath" "outputName" "type" ], which doesn’t look like it gives me much room for messing with.
I want to make a tool / function which can override an arbitrary derivation (to replace its
src attribute, specifically). I’ve tried this sort of thing before, and it tends to be kind of awkward to write this as a wrapper for
nix-build - you need to understand how to interpret paths,
-A flags, etc in order to construct a derivation which is like what
nix-build will do, but also injecting your wrapper function into the mix.
So I’m wondering if it’s possible to override the resulting derivation - i.e. take the arguments to nix-build, pass them to nix-instantiate instead, then modify that since that will boil anything down to a .drv file.