I stumbled over this today:
I wanted to override the inputs of a derivation, in that case the library mlt
, for kdenlive: Unsupported video codec: libaom-av1 · Issue #272526 · NixOS/nixpkgs · GitHub. mlt
in turn is used in another derivation, kdenlive
, in several places. So I thought, I’d just cram in a little let
block to do my override.
Before:
{ ...
, mlt
, ...
}:
mkDerivation {
pname = "kdenlive";
...
buildInputs = [... mlt ...];
inherit mlt;
}
After:
{ ...
, mlt
, ...
}:
let mlt = mlt.override { ffmpeg = ffmpeg-full; };
in mkDerivation {
pname = "kdenlive";
...
buildInputs = [... mlt ...];
inherit mlt;
}
Trouble is, this doesn’t work. It creates an infinite recursion. The mlt
on the right hand side of the equals sign is not the one bound in the function input, but the one defined on the left hand side of the equals sign. So I tinkered around and ended up with:
let
mlt-to-override = mlt;
in
let
mlt = mlt-to-override.override {
ffmpeg = ffmpeg-full;
};
in ...
But this strikes me as really ugly. Is there a better way to do this? Note that it wouldn’t be a good solution to inline the let
, because I need to add mlt
to the buildInputs
and as an attribute in the whole derivation.