[Nix-dev] Re: [Nix-commits] SVN commit: nix - 17661 - raskin - in nixpkgs/trunk/pkgs: development/libraries/avahi development/libraries/consolekit development/libraries/gstreamer development/libraries/gstreamer/gst-ffmpeg development/libraries/gstreamer/gst-pl

Nicolas Pierron nicolas.b.pierron at gmail.com
Tue Oct 6 10:39:25 CEST 2009


On Tue, Oct 6, 2009 at 07:43, Michael Raskin <7c6f434c at mail.ru> wrote:
> A case study in transitive overrides.

Is the trunk the right place for case study.  I am not blaming you,
but I am blaming us, even me.
One day we should discuss our commit policy and determine if the trunk
should remain stable or if we allow case studies inside it and create
stable tags.

> WebKit needs fresh glib. This means it needs a whole slice of system built against glib-2.22.. Added overrides are generic enough, though. So the same way can be used to override everything. I have failed (so far?) to add mkOverridable into stdenv, though.

> Modified: nixpkgs/trunk/pkgs/top-level/all-packages.nix
> ===================================================================
> --- nixpkgs/trunk/pkgs/top-level/all-packages.nix       2009-10-05 23:47:50 UTC (rev 17660)
> +++ nixpkgs/trunk/pkgs/top-level/all-packages.nix       2009-10-06 05:43:51 UTC (rev 17661)
> @@ -191,9 +191,16 @@
>   # let d = makeOverridable stdenv.mkDerivation { name = ..; buildInputs; }
>   #     noBuildInputs = d.override { buildInputs = []; }
>   #     additionalBuildInputs = d.override ( args : args // { buildInputs = args.buildInputs ++ [ additional ]; } )
> +  deepOverride = newArgs: name: x: if builtins.isAttrs x then (
> +    if x ? deepOverride then (x.deepOverride newArgs) else
> +    if x ? override then (x.override newArgs) else
> +    x) else x;
>   makeOverridable = f: origArgs: f origArgs //
>     { override = newArgs:
>         makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
> +      deepOverride = newArgs:
> +        makeOverridable f ((lib.mapAttrs (deepOverride newArgs) origArgs) // newArgs);
> +      origArgs = origArgs;
>     };
>
>
> @@ -439,7 +446,7 @@
>   avahi =
>     let qt4Support = getConfig [ "avahi" "qt4Support" ] false;
>     in
> -      import ../development/libraries/avahi {
> +      makeOverridable (import ../development/libraries/avahi) {
>         inherit stdenv fetchurl pkgconfig libdaemon dbus perl perlXMLParser
>           expat gettext intltool lib;
>         inherit (gtkLibs) glib gtk;
> @@ -3058,7 +3065,9 @@
>     inherit stdenv fetchurl lib;
>   };
>
> -  consolekit = import ../development/libraries/consolekit {
> +  consolekit = makeOverridable
> +      (import ../development/libraries/consolekit)
> +  {
>     inherit stdenv fetchurl pkgconfig dbus_glib zlib pam policykit expat;
>     inherit (gtkLibs) glib;
>     inherit (xlibs) libX11;
> @@ -3111,16 +3120,13 @@
>     useX11 = true; # !!! `false' doesn't build
>   };
>
> -  dbus_glib = import ../development/libraries/dbus-glib {
> +  dbus_glib = makeOverridable
> +      (import ../development/libraries/dbus-glib)
> +  {
>     inherit fetchurl stdenv pkgconfig gettext dbus expat;
>     inherit (gtkLibs) glib;
>   };
>

I think you should rename makeOverridable to makeUpdatable.  The
reason is that an override remove the access to the first content, and
in our case this allow you to update the content of a copy of the
first derivation.  As long as you don't modify the first attribute,
you cannot call it an override.

foo = makeOverridable ...;
bar = foo.override ...;

I'll prefer:

foo = makeUpdateable ...;
bar = foo.update ...;

This is similar to the following code if we remove the derivations.

foo = {...};
bar = foo // {...};


-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
Andrew S. Tanenbaum - Never underestimate the bandwith of a wagon full of tapes.



More information about the nix-dev mailing list