[Nix-dev] Re: [Nix-commits] SVN commit: nix - 12621 - eelco - in nix/trunk: src/libexpr tests/lang
Ludovic Courtès
ludo at gnu.org
Thu Aug 14 16:12:47 CEST 2008
Hi,
Eelco Dolstra <e.dolstra at tudelft.nl> writes:
> Author: eelco
> Date: 2008-08-14 14:00:44 +0000 (Thu, 14 Aug 2008)
> New Revision: 12621
> * Added an experimental feature suggested by Andres: ellipses ("...")
> in attribute set pattern matches. This allows defining a function
> that takes *at least* the listed attributes, while ignoring
> additional attributes. For instance,
>
> {stdenv, fetchurl, fuse, ...}:
>
> stdenv.mkDerivation {
> ...
> };
>
> defines a function that requires an attribute set that contains the
> specified attributes but ignores others. The main advantage is that
> we can then write in all-packages.nix
>
> aefs = import ../bla/aefs pkgs;
>
> instead of
>
> aefs = import ../bla/aefs {
> inherit stdenv fetchurl fuse;
> };
>
> This saves a lot of typing (not to mention not having to update
> all-packages.nix with purely mechanical changes). It saves as much
> typing as the "args: with args;" style, but has the advantage that
> the function arguments are properly declared (not implicit in what
> the body of the "with" uses).
By "ignoring additional attributes", you mean that the additional
attributes are not visible at all in the function body, right?
Otherwise this solution would have the same problems as the "args: with
args;" style, namely ambient authority.
Thanks,
Ludovic.
More information about the nix-dev
mailing list