2015-01-24 22:40:40 +03:00
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
2015-12-07 22:41:18 +03:00
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
xml:id="chap-packageconfig">
|
2015-01-24 22:40:40 +03:00
|
|
|
|
2017-02-01 18:03:42 +03:00
|
|
|
<title>Global configuration</title>
|
2015-01-24 22:40:40 +03:00
|
|
|
|
2015-12-07 22:41:18 +03:00
|
|
|
<para>Nix packages can be configured to allow or deny certain options.</para>
|
|
|
|
|
|
|
|
<para>To apply the configuration edit
|
2017-02-01 18:03:42 +03:00
|
|
|
<filename>~/.config/nixpkgs/config.nix</filename> and set it like
|
2015-01-25 23:26:05 +03:00
|
|
|
|
2015-12-07 22:41:18 +03:00
|
|
|
<programlisting>
|
|
|
|
{
|
2015-02-15 20:29:52 +03:00
|
|
|
allowUnfree = true;
|
2015-12-07 22:41:18 +03:00
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
and will allow the Nix package manager to install unfree licensed packages.</para>
|
|
|
|
|
|
|
|
<para>The configuration as listed also applies to NixOS under
|
|
|
|
<option>nixpkgs.config</option> set.</para>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
2016-05-23 13:02:46 +03:00
|
|
|
Example to allow flash player and visual studio code only:
|
2015-12-07 22:41:18 +03:00
|
|
|
|
|
|
|
<programlisting>
|
2016-05-23 13:02:46 +03:00
|
|
|
allowUnfreePredicate = with builtins; (pkg: elem (parseDrvName pkg.name).name [ "flashplayer" "vscode" ]);
|
2015-12-07 22:41:18 +03:00
|
|
|
</programlisting>
|
2015-01-25 23:26:05 +03:00
|
|
|
|
2015-01-24 22:40:40 +03:00
|
|
|
</para>
|
2015-12-07 22:41:18 +03:00
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Whenever unfree packages are not allowed, packages can still
|
|
|
|
be whitelisted by their license:
|
2015-01-24 22:40:40 +03:00
|
|
|
|
2015-12-07 22:41:18 +03:00
|
|
|
<programlisting>
|
|
|
|
whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ];
|
|
|
|
</programlisting>
|
2015-01-25 16:30:27 +03:00
|
|
|
</para>
|
2015-12-07 22:41:18 +03:00
|
|
|
</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>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 18:54:39 +03:00
|
|
|
|
2015-05-31 19:41:34 +03:00
|
|
|
<section xml:id="sec-modify-via-packageOverrides"><title>Modify
|
|
|
|
packages via <literal>packageOverrides</literal></title>
|
2015-04-20 18:54:39 +03:00
|
|
|
|
2015-12-07 22:41:18 +03:00
|
|
|
<para>You can define a function called
|
|
|
|
<varname>packageOverrides</varname> in your local
|
2017-02-01 18:03:42 +03:00
|
|
|
<filename>~/.config/nixpkgs/config.nix</filename> to overide nix packages. It
|
2015-12-07 22:41:18 +03:00
|
|
|
must be a function that takes pkgs as an argument and return modified
|
|
|
|
set of packages.
|
2015-04-21 00:09:45 +03:00
|
|
|
|
2015-12-07 22:41:18 +03:00
|
|
|
<programlisting>
|
|
|
|
{
|
2015-04-21 00:09:45 +03:00
|
|
|
packageOverrides = pkgs: rec {
|
|
|
|
foo = pkgs.foo.override { ... };
|
|
|
|
};
|
2015-12-07 22:41:18 +03:00
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
|
2015-04-20 18:54:39 +03:00
|
|
|
</para>
|
2015-12-07 22:41:18 +03:00
|
|
|
|
2015-04-20 18:54:39 +03:00
|
|
|
</section>
|
2015-01-25 16:30:27 +03:00
|
|
|
|
2015-12-07 22:41:18 +03:00
|
|
|
|
2015-04-20 18:54:39 +03:00
|
|
|
</chapter>
|