1<chapter xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xml:id="chap-packageconfig">
4
5<title><filename>~/.nixpkgs/config.nix</filename>: global configuration</title>
6
7 <para>
8 Nix packages can be configured to allow or deny certain options.
9 </para>
10
11 <para>
12 To apply the configuration edit <filename>~/.nixpkgs/config.nix</filename>
13 and set it like
14<programlisting>{
15 allowUnfree = true;
16}</programlisting>
17 and will allow the Nix package manager to install unfree licensed packages.
18
19 The configuration as listed also applies to NixOS under <option>nixpkgs.config</option> set.
20 </para>
21
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.
68 </para>
69
70<section xml:id="sec-modify-via-packageOverrides"><title>Modify
71packages via <literal>packageOverrides</literal></title>
72
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.
79
80 <programlisting>{
81 packageOverrides = pkgs: rec {
82 foo = pkgs.foo.override { ... };
83 };
84}</programlisting>
85</para>
86</section>
87
88</chapter>