[Nix-dev] Re: New proposal about expression syntax usage.

apfelmus apfelmus at quantentunnel.de
Wed Aug 15 10:21:01 CEST 2007


Michael Raskin wrote:
> Now packages are written like this:
> 
> some = import ../some {inherit ncurses;}
> 
> --- some/default.nix
> 
> {ncurses}:
> {
> buildInputs = [ncurses];
> }
> 
> ---
> 
> Here the list of dependencies (a thing likely to change!) is repeated 3
> times - two of them in supposedly small file some/default.nix .
> Technically speaking, nix can check even that passed arguments are all
> taken by function, but not that they are really used (and not forgot).
> 
> I think that one repeat per file is enough in most cases. So in
> pkgs/servers/irc/ircd-hybrid I used proposed new form:
> 
> args:
> {
> buildInputs = (with args; [ncurses]);
> }

I'm not sure whether this is a good idea. The advantage of naming the 
arguments explicitly like in

  {stdenv, fetchurl, ncurses} : ...

is that nix can check that these and only these arguments are passed to 
the function. I.e. nix performs (does it?) a pattern match on the argument.

On the other hand, the repetition is not good either. In Haskell, one 
can name the parameter and still pattern match on it. In nix, that could 
look like

  args@{stdenv, fetchurl, ncurses} : ...

In the function body, both the whole attribute set  args  and the 
matched attributes  stdenv, fetchurl  and  ncurses  are in scope. Given 
a function that converts an attribute set to a list, we could write

  buildInputs = toList args;

Of course, this assumes that all arguments are derivations and not flags.


Regards,
apfelmus




More information about the nix-dev mailing list