[Nix-dev] deepOverride (was [Nix-commits] SVN commit: nix - 22529 - raskin - in nixpkgs/trunk/pkgs: development/interpreters/perl-5.10 development/interpreters/python/2.6 development/libraries/avahi development/libraries/cairo development/libraries/consolekit development/libraries/enchant development/libraries/freetype development/libraries/libjpeg development/libraries/libxml2 development/libraries/openssl development/libraries/zlib development/tools/misc/gnum4 lib os-specific/linux/hal servers/pulseaudio tools/networking/curl top-level)
Marc Weber
marco-oweber at gmx.de
Fri Jul 9 18:58:02 CEST 2010
Hi Michael Raskin & list,
Excerpts from Michael Raskin's message of Fri Jul 09 17:30:01 +0200 2010:
> - From what I see, this combination will have a problem with libB using
> libA linked against version y.
x: default
y: development
z: git
libB depnds on both:
- (libA depending on y)
- z
Now libB wants to override dependency y in libA so that z is used
everywhere.
Solution (paste this at the end of your all-packages.nix):
pkgsFunDeepOverride = overrides: pkgsFun (overrides // __overrides);
test_libsoup_x = simpleLib "libsoup-x-stable" [];
test_libsoup_y = simpleLib "libsoup-y-development" [];
test_libsoup_z = simpleLib "libsoup-z-git" [];
test_libsoup_user = simpleLib "libsoup-user" []; # use this in your packageOverrides (~/.nixpkgs/config.nix)
test_libsoup = test_libsoup_x; # default as used often in nixpgks
simpleLib = name: deps: stdenv.mkDerivation {
inherit name;
inherit deps;
unpackPhase = ":";
installPhase = ''
ensureDir $out
echo ${name} >> $out/name
for d in $deps; do echo $d >> $out/deps; done
'';
};
libA =
let overriddenPkgs = pkgsFunDeepOverride { test_libsoup = test_libsoup_y; };
mylibsoup = overriddenPkgs.test_libsoup;
in simpleLib "libA-should-depend-on-${mylibsoup.name}-defaulting-to-y"
[mylibsoup];
libB =
let overriddenPkgs = pkgsFunDeepOverride { test_libsoup = test_libsoup_z; };
in simpleLib "libB-should-depend-on-libsoup-z-and-on-libA-depending-on-libsoup-z"
[
overriddenPkgs.libA
overriddenPkgs.test_libsoup
];
Then nix-build libA and libB
libA/deps:
/nix/store/csshhli6cz15219hj698qzy57bv88syx-libsoup-y-development
libB/deps:
/nix/store/4ljlpf57ynyy2xg26wzm5hk7174jak46-libA-should-depend-on-libsoup-z-git-defaulting-to-y
/nix/store/gb61fmnblqbr20ac9n5brs4p7va8wzk6-libsoup-z-git
So both depend on z.
This test case shows that Eelco Dolstra found an alternative way to
express what deepOverride did. In contrast to deepOverride it doesn't
override argument names. So name collisions can't happen.
The user can still override everything. Eg if he uses
packageOverrides = {
test_libsoup = pkgs.test_libsoup_user;
}
Dependencies change this way:
libA:
/nix/store/x0mzzvi2qg1s9rpbpis4368z3xz2bmlz-libsoup-user
libB:
/nix/store/z9jnn3yg5q9fbddy3634j8jscn43v4hi-libA-should-depend-on-libsoup-user-defaulting-to-y
/nix/store/x0mzzvi2qg1s9rpbpis4368z3xz2bmlz-libsoup-user
Which shows that the user overrides the packageOverrides .. whether this
is desired behaviour - I don't know. Don't think this is a problem.
Does someone disagree on removing deepOverrides - reimplementing its
usages using the new style?
Marc Weber
More information about the nix-dev
mailing list