[Nix-dev] ‘callPackage’ vs. ‘all-packages.nix’

Eelco Dolstra e.dolstra at tudelft.nl
Tue Sep 15 23:21:22 CEST 2009


Hi,

Marc Weber wrote:

>>>     - Use "{ arg1, arg2, ... }:" in the package's function definition
>>>       (i.e. use the ellipis "..." to allow arbitrary additional
>>>       arguments), and then call the function with all of "pkgs" as an
>>>       argument.  But this inhibits error detection if you call it with
>>>       an misspelled (or obsolete) argument.
> 
> Eelco Dolstra, can you explain this inhibiting of error detection?
> 
> I mean when writing this:
> 
>   all-packages.nix :
> 
>     vice = import ../misc/emulators/vice pkgs;
> 
>   vice/default.nix :
> 
>     { dep1, dep2, ... }:
> 
>     [..]
> 
>     buildInputs = [ dep1 dep2 ];
> 
> you can't misspell dep1 dep2 without passing wrong arguments.

If a formal argument has a default, you can:

  { dep1, dep2 ? null, ... }:

called with

  import ./foo { inherit dep1; deb2 = bla; };

won't give an error.

Also, if formal arguments are removed, you may want to know about the fact that
you are calling it with obsolete arguments.

> So what makes the difference exactly?
> It even adds a redundant function call to each package (thus some
> complexity) to all-packages.nix.

It won't, since it will subsume the functionality of functions such as
makeOverridable, which is currently applied fairly arbitrarily.  It could also
include the functionality of selectVersion, but then I've never understood what
that was for.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/



More information about the nix-dev mailing list