1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-18 07:08:27 +02:00

* 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).
This commit is contained in:
Eelco Dolstra 2008-08-14 14:00:44 +00:00
parent db4f4a8425
commit 9279174dde
14 changed files with 57 additions and 23 deletions

View file

@ -22,6 +22,16 @@
<attr name="c">
<string value="foobar" />
</attr>
<attr name="ellipsis">
<function>
<attrspat>
<attr name="x" />
<attr name="y" />
<attr name="z" />
<ellipsis />
</attrspat>
</function>
</attr>
<attr name="f">
<function>
<attrspat>