[Nix-dev] Overriding mutually dependent derivations

Ludovic Courtès ludo at gnu.org
Thu Apr 5 22:23:34 CEST 2012


Hello!

Suppose these packages:

  a = foo b c;
  b = bar c;
  c = baz ...;

What if I want to call ‘overrideDerivation’ for each of them, yet have
each of the overridden packages refer to its overridden friends?

The naive approach fails:

  config.packageOverrides = pkgs: {
    a = pkgs.lib.overrideDerivation pkgs.a ...;
    b = pkgs.lib.overrideDerivation pkgs.b ...;
    c = pkgs.lib.overrideDerivation pkgs.c ...;
  };

The problem here is that the new ‘a’ will refer to the old ‘b’ and ‘c’,
and the new ‘b’ will refer to the old ‘c’.

When everything goes well, the following approach solves the problem:

  config.packageOverrides = pkgs: rec {
    a = pkgs.lib.overrideDerivation (pkgs.a.override { inherit b c; }) ...;
    b = pkgs.lib.overrideDerivation (pkgs.b.override { inherit c; }) ...;
    c = pkgs.lib.overrideDerivation pkgs.c ...;
  };

… at the expense of readability and convenience.

Any better idea?

Thanks,
Ludo’.



More information about the nix-dev mailing list