at 16.09-beta 2.9 kB view raw
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>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 11 12<programlisting> 13{ 14 allowUnfree = true; 15} 16</programlisting> 17 18and 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> 46allowUnfreePredicate = (pkg: ...); 47</programlisting> 48 49 Example to allow flash player and visual studio code only: 50 51<programlisting> 52allowUnfreePredicate = with builtins; (pkg: elem (parseDrvName pkg.name).name [ "flashplayer" "vscode" ]); 53</programlisting> 54 55 </para> 56 </listitem> 57 58 <listitem> 59 <para>Whenever unfree packages are not allowed, packages can still 60 be whitelisted by their license: 61 62<programlisting> 63whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ]; 64</programlisting> 65 </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> 74blacklistedLicenses = 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<!--============================================================--> 86 87<section xml:id="sec-modify-via-packageOverrides"><title>Modify 88packages via <literal>packageOverrides</literal></title> 89 90<para>You can define a function called 91<varname>packageOverrides</varname> in your local 92<filename>~/.nixpkgs/config.nix</filename> to overide nix packages. It 93must be a function that takes pkgs as an argument and return modified 94set of packages. 95 96<programlisting> 97{ 98 packageOverrides = pkgs: rec { 99 foo = pkgs.foo.override { ... }; 100 }; 101} 102</programlisting> 103 104</para> 105 106</section> 107 108 109</chapter>