nixpkgs/doc/packageconfig.xml

84 lines
2.7 KiB
XML
Raw Normal View History

<chapter xmlns="http://docbook.org/ns/docbook"
2015-04-20 09:54:39 -06:00
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:id="chap-packageconfig">
2015-02-15 10:29:52 -07:00
<title><filename>~/.nixpkgs/config.nix</filename>: global configuration</title>
<para>
2015-02-15 10:29:52 -07:00
Nix packages can be configured to allow or deny certain options.
</para>
<para>
2015-04-20 09:54:39 -06:00
To apply the configuration edit <filename>~/.nixpkgs/config.nix</filename>
and set it like
2015-02-15 10:29:52 -07:00
<programlisting>{
allowUnfree = true;
}</programlisting>
2015-04-20 09:54:39 -06:00
and will allow the Nix package manager to install unfree licensed packages.
2015-04-20 09:54:39 -06:00
The configuration as listed also applies to NixOS under <option>nixpkgs.config</option> set.
</para>
<itemizedlist>
2015-04-20 09:54:39 -06:00
<listitem>
<para>
Allow installing of packages that are distributed under unfree license by setting
<programlisting>allowUnfree = true;</programlisting>
or deny them by setting it to <literal>false</literal>.
</para>
<para>
Same can be achieved by setting the environment variable:
<programlisting>$ export NIXPKGS_ALLOW_UNFREE=1</programlisting>
</para>
</listitem>
<listitem>
<para>
Whenever unfree packages are not allowed, single packages can
still be allowed by a predicate function that accepts package
as an argument and should return a boolean:
<programlisting>allowUnfreePredicate = (pkg: ...);</programlisting>
Example to allow flash player only:
<programlisting>allowUnfreePredicate = (pkg: pkgs.lib.hasPrefix "flashplayer-" pkg.name);</programlisting>
</para>
</listitem>
<listitem>
<para>
Whenever unfree packages are not allowed, packages can still be
whitelisted by their license:
<programlisting>whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ];</programlisting>
</para>
</listitem>
<listitem>
<para>
In addition to whitelisting licenses which are denied by the
<literal>allowUnfree</literal> setting, you can also explicitely
deny installation of packages which have a certain license:
<programlisting>blacklistedLicenses = with stdenv.lib.licenses; [ agpl3 gpl3 ];</programlisting>
</para>
</listitem>
</itemizedlist>
<para>
2015-04-20 09:54:39 -06:00
A complete list of licenses can be found in the file
<filename>lib/licenses.nix</filename> of the nix package tree.
</para>
2015-04-20 09:54:39 -06:00
<section><title>Modify packages via<literal>packageOverrides</literal></title>
2015-04-20 09:54:39 -06:00
<para>
<filename>~/.nixpkgs/config.nix</filename> enables the user to
override package names without creating a fork of Nixpkgs. This is
accomplished by defining a function called
<varname>packageOverrides</varname>. It is expected to take the set
of packages, usually called <varname>pkgs</varname>, and returns a
modified set of packages. It is called when evaluating any nix
expression in the <varname>pkgs</varname> set.
2015-04-20 09:54:39 -06:00
</para>
</section>
2015-04-20 09:54:39 -06:00
</chapter>