[Nix-dev] applyAndFun again - kernel derivation proposal and example

Nicolas Pierron nicolas.b.pierron at gmail.com
Tue Feb 24 10:54:11 CET 2009


Hi Marc,

On Tue, Feb 24, 2009 at 03:31, Marc Weber <marco-oweber at gmx.de> wrote:
> To test it simply insert the code somewhere in lib.
>
> changes:
>  no longer using passthru, the "special" names are removed before the
>  args are applied to the given funtion.
>  The function contains the possibility to pass either a function
>  (taking the previously supplied args) or attrs hardcoded now.

Key function that you have paste here seems simple even if the naming
is not helping much.  So the basic operation that you are doing are:

AddMergeAndReplaceFunction (
  f ( # mkDerivation
    removeSpecialAttributes ( # old tidy
      (fix arg) # fix takeFixed
    )
  )
)

The merge and the replace function are waiting for an extra argument
which can be define either inside the new argument or inside the
initial version.

One thing which is not clear to me is:
  args // { inherit fixed; }

because you can either use the old value and the new value at the same
time, and apparently in real life example you are frequently using
"fixed" attributes.  So I will suggest something like:

  { old = args; } // fixed

The old attribute will only be used once in your dummy example:

>    res5 = let x = defaultOverridableDelayableArgs id { a = 7; };
>          in (x.merge) ( x: { a = __add x.a 3; });
>    # { a = 10; }

Which illustrate that you want to extend something which was not made
to be extensible.

> real world example :
> ...

So the kernel derivation is no longer a derivation but it is a
template which can be instantiated with different kernel version.
This is very nice because with this we can factor code and keep the
common stuff inside one derivationTemplate (could that be a better
name for your work ?) and with can override some parts of it to get a
similar template or derivation (which was a bit hacky with file with
arguments)


-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list