mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 18:26:16 +02:00
9279174dde
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).
53 lines
1.1 KiB
XML
53 lines
1.1 KiB
XML
<?xml version='1.0' encoding='utf-8'?>
|
|
<expr>
|
|
<attrs>
|
|
<attr name="a">
|
|
<string value="foo" />
|
|
</attr>
|
|
<attr name="at">
|
|
<function>
|
|
<at>
|
|
<varpat name="args" />
|
|
<attrspat>
|
|
<attr name="x" />
|
|
<attr name="y" />
|
|
<attr name="z" />
|
|
</attrspat>
|
|
</at>
|
|
</function>
|
|
</attr>
|
|
<attr name="b">
|
|
<string value="bar" />
|
|
</attr>
|
|
<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>
|
|
<attr name="z" />
|
|
<attr name="x" />
|
|
<attr name="y" />
|
|
</attrspat>
|
|
</function>
|
|
</attr>
|
|
<attr name="id">
|
|
<function>
|
|
<varpat name="x" />
|
|
</function>
|
|
</attr>
|
|
<attr name="x">
|
|
<int value="123" />
|
|
</attr>
|
|
</attrs>
|
|
</expr>
|