@@ -1,88 +1,109 @@
11<chapter xmlns="http://docbook.org/ns/docbook"
2− xmlns:xlink="http://www.w3.org/1999/xlink"
3− xml:id="chap-packageconfig">
2+ xmlns:xlink="http://www.w3.org/1999/xlink"
3+ xml:id="chap-packageconfig">
44
55<title><filename>~/.nixpkgs/config.nix</filename>: global configuration</title>
66
7− <para>
8− Nix packages can be configured to allow or deny certain options.
9− </para>
7+<para>Nix packages can be configured to allow or deny certain options.</para>
8+
9+<para>To apply the configuration edit
10+<filename>~/.nixpkgs/config.nix</filename> and set it like
1011
11− <para>
12− To apply the configuration edit <filename>~/.nixpkgs/config.nix</filename>
13− and set it like
14−<programlisting>{
12+<programlisting>
13+{
1514 allowUnfree = true;
16−}</programlisting>
17− and will allow the Nix package manager to install unfree licensed packages.
15+}
16+</programlisting>
17+
18+and will allow the Nix package manager to install unfree licensed packages.</para>
19+
20+<para>The configuration as listed also applies to NixOS under
21+<option>nixpkgs.config</option> set.</para>
22+
23+<itemizedlist>
24+
25+ <listitem>
26+ <para>Allow installing of packages that are distributed under
27+ unfree license by setting <programlisting>allowUnfree =
28+ true;</programlisting> or deny them by setting it to
29+ <literal>false</literal>.</para>
30+
31+ <para>Same can be achieved by setting the environment variable:
32+
33+<programlisting>
34+$ export NIXPKGS_ALLOW_UNFREE=1
35+</programlisting>
36+
37+ </para>
38+ </listitem>
39+
40+ <listitem>
41+ <para>Whenever unfree packages are not allowed, single packages
42+ can still be allowed by a predicate function that accepts package
43+ as an argument and should return a boolean:
44+
45+<programlisting>
46+allowUnfreePredicate = (pkg: ...);
47+</programlisting>
48+
49+ Example to allow flash player only:
50+
51+<programlisting>
52+allowUnfreePredicate = (pkg: pkgs.lib.hasPrefix "flashplayer-" pkg.name);
53+</programlisting>
1854
19− The configuration as listed also applies to NixOS under <option>nixpkgs.config</option> set.
2055 </para>
56+ </listitem>
57+
58+ <listitem>
59+ <para>Whenever unfree packages are not allowed, packages can still
60+ be whitelisted by their license:
2161
22− <itemizedlist>
23− <listitem>
24− <para>
25− Allow installing of packages that are distributed under unfree license by setting
26− <programlisting>allowUnfree = true;</programlisting>
27− or deny them by setting it to <literal>false</literal>.
28− </para>
29− <para>
30− Same can be achieved by setting the environment variable:
31− <programlisting>$ export NIXPKGS_ALLOW_UNFREE=1</programlisting>
32− </para>
33− </listitem>
34−
35− <listitem>
36− <para>
37− Whenever unfree packages are not allowed, single packages can
38− still be allowed by a predicate function that accepts package
39− as an argument and should return a boolean:
40− <programlisting>allowUnfreePredicate = (pkg: ...);</programlisting>
41−
42− Example to allow flash player only:
43− <programlisting>allowUnfreePredicate = (pkg: pkgs.lib.hasPrefix "flashplayer-" pkg.name);</programlisting>
44− </para>
45− </listitem>
46−
47− <listitem>
48− <para>
49− Whenever unfree packages are not allowed, packages can still be
50− whitelisted by their license:
51− <programlisting>whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ];</programlisting>
52− </para>
53− </listitem>
54−
55− <listitem>
56− <para>
57− In addition to whitelisting licenses which are denied by the
58− <literal>allowUnfree</literal> setting, you can also explicitely
59− deny installation of packages which have a certain license:
60− <programlisting>blacklistedLicenses = with stdenv.lib.licenses; [ agpl3 gpl3 ];</programlisting>
61− </para>
62− </listitem>
63− </itemizedlist>
64−
65− <para>
66− A complete list of licenses can be found in the file
67− <filename>lib/licenses.nix</filename> of the nix package tree.
62+<programlisting>
63+whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ];
64+</programlisting>
6865 </para>
66+ </listitem>
67+
68+ <listitem>
69+ <para>In addition to whitelisting licenses which are denied by the
70+ <literal>allowUnfree</literal> setting, you can also explicitely
71+ deny installation of packages which have a certain license:
72+
73+<programlisting>
74+blacklistedLicenses = with stdenv.lib.licenses; [ agpl3 gpl3 ];
75+</programlisting>
76+ </para>
77+ </listitem>
78+
79+</itemizedlist>
80+
81+<para>A complete list of licenses can be found in the file
82+<filename>lib/licenses.nix</filename> of the nix package tree.</para>
83+
84+
85+<!--============================================================-->
6986
7087<section xml:id="sec-modify-via-packageOverrides"><title>Modify
7188packages via <literal>packageOverrides</literal></title>
7289
73−<para>
74−
75− You can define a function called <varname>packageOverrides</varname>
76− in your local <filename>~/.nixpkgs/config</filename> to overide nix
77− packages. It must be a function that takes pkgs as an argument and
78− return modified set of packages.
90+<para>You can define a function called
91+<varname>packageOverrides</varname> in your local
92+<filename>~/.nixpkgs/config</filename> to overide nix packages. It
93+must be a function that takes pkgs as an argument and return modified
94+set of packages.
7995
80− <programlisting>{
96+<programlisting>
97+{
8198 packageOverrides = pkgs: rec {
8299 foo = pkgs.foo.override { ... };
83100 };
84−}</programlisting>
101+}
102+</programlisting>
103+
85104</para>
105+
86106</section>
87107
108+
88109</chapter>