I need to override the Nixpkgs PulseAudio version and thought I’d try learning overlays in the same go. I started out with this:
(self: super:
{
pulseaudio = super.pulseaudio.overrideAttrs (_: rec {
version = "13.99";
src = super.fetchurl {
url = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${version}.1.tar.xz";
sha256 = "030a7v0khp6w683km81c6vpch1687pvx2gvscnzkjq4f0z6138g6";
};
});
}
)
The relevant parts of the recipe whose derivation I’m overriding is:
{ (...) libOnly ? false (...) }:
stdenv.mkDerivation rec {
name = "${if libOnly then "lib" else ""}pulseaudio-${version}";
version = "13.0";
src = fetchurl {
url = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${version}.tar.xz";
sha256 = "0mw0ybrqj7hvf8lqs5gjzip464hfnixw453lr0mqzlng3b5266wn";
};
(...)
postInstall = lib.optionalString libOnly ''
rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}}
sed 's|-lltdl|-L${libtool.lib}/lib -lltdl|' -i $out/lib/pulseaudio/libpulsecore-${version}.la
''
+ (...)
From what I gather, overrideAttrs
produces a recipe with a new attribute set that mkDerivation
will evaluate when called. That is, any non-overridden attribute that refers to an overridden attribute - such as version
in my example - will use the overridden attribute when evaluated. This is as opposed to overrideDerivation
, which results in mkDerivation
being evaluated before applying the overridden attributes.
But with my first overlay attempt, postInstall
still uses the old version
attribute, and therefore building it with libOnly = true
fails. So I tried adding this line:
postInstall = super.pulseaudio.postInstall;
This works, which makes me think that super.pulseaudio.postInstall
is “inlined” when I declare it this way. Therefore, I would expect the same to be true for name
when I add this:
name = super.pulseaudio.name;
But it isn’t - the resulting derivation, although fully functional with the overridden version, has an output path that still uses the old version name. (I realize that pname
solves this, but I can only work with the original recipe as it is.)
What am I not understanding here? Why does it work for postInstall
(and is that an idiomatic way to do it?) but not name
, and how am I reading the Nixpkgs manual wrong when it comes to overrideAttrs
?