about summary refs log tree commit diff
path: root/nixos/doc/manual/configuration/abstractions.xml
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/doc/manual/configuration/abstractions.xml')
-rw-r--r--nixos/doc/manual/configuration/abstractions.xml48
1 files changed, 36 insertions, 12 deletions
diff --git a/nixos/doc/manual/configuration/abstractions.xml b/nixos/doc/manual/configuration/abstractions.xml
index 6e6850769f5d..5bf0635cc1aa 100644
--- a/nixos/doc/manual/configuration/abstractions.xml
+++ b/nixos/doc/manual/configuration/abstractions.xml
@@ -6,7 +6,8 @@
  <title>Abstractions</title>
 
  <para>
-  If you find yourself repeating yourself over and over, it’s time to abstract. Take, for instance, this Apache HTTP Server configuration:
+  If you find yourself repeating yourself over and over, it’s time to
+  abstract. Take, for instance, this Apache HTTP Server configuration:
 <programlisting>
 {
   <xref linkend="opt-services.httpd.virtualHosts"/> =
@@ -26,7 +27,9 @@
     ];
 }
 </programlisting>
-  It defines two virtual hosts with nearly identical configuration; the only difference is that the second one has SSL enabled. To prevent this duplication, we can use a <literal>let</literal>:
+  It defines two virtual hosts with nearly identical configuration; the only
+  difference is that the second one has SSL enabled. To prevent this
+  duplication, we can use a <literal>let</literal>:
 <programlisting>
 let
   exampleOrgCommon =
@@ -47,11 +50,16 @@ in
     ];
 }
 </programlisting>
-  The <literal>let exampleOrgCommon = <replaceable>...</replaceable></literal> defines a variable named <literal>exampleOrgCommon</literal>. The <literal>//</literal> operator merges two attribute sets, so the configuration of the second virtual host is the set <literal>exampleOrgCommon</literal> extended with the SSL options.
+  The <literal>let exampleOrgCommon = <replaceable>...</replaceable></literal>
+  defines a variable named <literal>exampleOrgCommon</literal>. The
+  <literal>//</literal> operator merges two attribute sets, so the
+  configuration of the second virtual host is the set
+  <literal>exampleOrgCommon</literal> extended with the SSL options.
  </para>
 
  <para>
-  You can write a <literal>let</literal> wherever an expression is allowed. Thus, you also could have written:
+  You can write a <literal>let</literal> wherever an expression is allowed.
+  Thus, you also could have written:
 <programlisting>
 {
   <xref linkend="opt-services.httpd.virtualHosts"/> =
@@ -61,11 +69,16 @@ in
     ];
 }
 </programlisting>
-  but not <literal>{ let exampleOrgCommon = <replaceable>...</replaceable>; in <replaceable>...</replaceable>; }</literal> since attributes (as opposed to attribute values) are not expressions.
+  but not <literal>{ let exampleOrgCommon = <replaceable>...</replaceable>; in
+  <replaceable>...</replaceable>; }</literal> since attributes (as opposed to
+  attribute values) are not expressions.
  </para>
 
  <para>
-  <emphasis>Functions</emphasis> provide another method of abstraction. For instance, suppose that we want to generate lots of different virtual hosts, all with identical configuration except for the host name. This can be done as follows:
+  <emphasis>Functions</emphasis> provide another method of abstraction. For
+  instance, suppose that we want to generate lots of different virtual hosts,
+  all with identical configuration except for the host name. This can be done
+  as follows:
 <programlisting>
 {
   <xref linkend="opt-services.httpd.virtualHosts"/> =
@@ -83,11 +96,15 @@ in
       ];
 }
 </programlisting>
-  Here, <varname>makeVirtualHost</varname> is a function that takes a single argument <literal>name</literal> and returns the configuration for a virtual host. That function is then called for several names to produce the list of virtual host configurations.
+  Here, <varname>makeVirtualHost</varname> is a function that takes a single
+  argument <literal>name</literal> and returns the configuration for a virtual
+  host. That function is then called for several names to produce the list of
+  virtual host configurations.
  </para>
 
  <para>
-  We can further improve on this by using the function <varname>map</varname>, which applies another function to every element in a list:
+  We can further improve on this by using the function <varname>map</varname>,
+  which applies another function to every element in a list:
 <programlisting>
 {
   <xref linkend="opt-services.httpd.virtualHosts"/> =
@@ -97,11 +114,15 @@ in
       [ "example.org" "example.com" "example.gov" "example.nl" ];
 }
 </programlisting>
-  (The function <literal>map</literal> is called a <emphasis>higher-order function</emphasis> because it takes another function as an argument.)
+  (The function <literal>map</literal> is called a <emphasis>higher-order
+  function</emphasis> because it takes another function as an argument.)
  </para>
 
  <para>
-  What if you need more than one argument, for instance, if we want to use a different <literal>documentRoot</literal> for each virtual host? Then we can make <varname>makeVirtualHost</varname> a function that takes a <emphasis>set</emphasis> as its argument, like this:
+  What if you need more than one argument, for instance, if we want to use a
+  different <literal>documentRoot</literal> for each virtual host? Then we can
+  make <varname>makeVirtualHost</varname> a function that takes a
+  <emphasis>set</emphasis> as its argument, like this:
 <programlisting>
 {
   <xref linkend="opt-services.httpd.virtualHosts"/> =
@@ -119,7 +140,9 @@ in
       ];
 }
 </programlisting>
-  But in this case (where every root is a subdirectory of <filename>/sites</filename> named after the virtual host), it would have been shorter to define <varname>makeVirtualHost</varname> as
+  But in this case (where every root is a subdirectory of
+  <filename>/sites</filename> named after the virtual host), it would have been
+  shorter to define <varname>makeVirtualHost</varname> as
 <programlisting>
 makeVirtualHost = name:
   { hostName = name;
@@ -127,6 +150,7 @@ makeVirtualHost = name:
     adminAddr = "alice@example.org";
   };
 </programlisting>
-  Here, the construct <literal>${<replaceable>...</replaceable>}</literal> allows the result of an expression to be spliced into a string.
+  Here, the construct <literal>${<replaceable>...</replaceable>}</literal>
+  allows the result of an expression to be spliced into a string.
  </para>
 </section>