diff options
Diffstat (limited to 'doc/manual/expressions/builtins.xml')
-rw-r--r-- | doc/manual/expressions/builtins.xml | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/doc/manual/expressions/builtins.xml b/doc/manual/expressions/builtins.xml index 163153380ce4..f46a93ae0d5d 100644 --- a/doc/manual/expressions/builtins.xml +++ b/doc/manual/expressions/builtins.xml @@ -65,7 +65,7 @@ available as <function>builtins.derivation</function>.</para> <replaceable>set</replaceable></term> <listitem><para>Return the names of the attributes in the set - <replaceable>set</replaceable> in alphabetically sorted list. For instance, + <replaceable>set</replaceable> in an alphabetically sorted list. For instance, <literal>builtins.attrNames { y = 1; x = "foo"; }</literal> evaluates to <literal>[ "x" "y" ]</literal>.</para></listitem> @@ -213,10 +213,11 @@ if builtins ? getEnv then builtins.getEnv "PATH" else ""</programlisting> <varlistentry><term><function>builtins.match</function> <replaceable>regex</replaceable> <replaceable>str</replaceable></term> - <listitem><para>Returns a list if - <replaceable>regex</replaceable> matches - <replaceable>str</replaceable> precisely, otherwise returns <literal>null</literal>. - Each item in the list is a regex group. + <listitem><para>Returns a list if the <link + xlink:href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04">extended + POSIX regular expression</link> <replaceable>regex</replaceable> + matches <replaceable>str</replaceable> precisely, otherwise returns + <literal>null</literal>. Each item in the list is a regex group. <programlisting> builtins.match "ab" "abc" @@ -236,6 +237,11 @@ builtins.match "a(b)(c)" "abc" Evaluates to <literal>[ "b" "c" ]</literal>. +<programlisting> +builtins.match "[[:space:]]+([[:upper:]]+)[[:space:]]+" " FOO " +</programlisting> + +Evaluates to <literal>[ "foo" ]</literal>. </para></listitem> </varlistentry> @@ -292,6 +298,24 @@ with import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixo stdenv.mkDerivation { … } </programlisting> + Note that when obtaining the hash with <varname>nix-prefetch-url + </varname> the option <varname>--unpack</varname> is required. + </para> + + <para>This function can also verify the contents against a hash. + In that case, the function takes a set instead of a URL. The set + requires the attribute <varname>url</varname> and the attribute + <varname>sha256</varname>, e.g. + +<programlisting> +with import (fetchTarball { + url = https://github.com/NixOS/nixpkgs-channels/archive/nixos-14.12.tar.gz; + sha256 = "1jppksrfvbk5ypiqdz4cddxdl8z6zyzdb2srq8fcffr327ld5jj2"; +}) {}; + +stdenv.mkDerivation { … } +</programlisting> + </para> <para>This function is not available if <link |