summary refs log tree commit diff
path: root/doc/functions.xml
blob: 16f4f262a25f9b5e3d436d4aedabb968cde86bd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<chapter xmlns="http://docbook.org/ns/docbook"
	 xmlns:xlink="http://www.w3.org/1999/xlink"
	 xml:id="chap-functions">

<title>Functions reference</title>

<para>
  The nixpkgs repository has several utility functions to manipulate Nix expressions.
</para>

<section xml:id="sec-pkgs-overridePackages">
  <title>pkgs.overridePackages</title>

  <para>
    This function inside the nixpkgs expression (<varname>pkgs</varname>)
    can be used to override the set of packages itself.
  </para>
  <para>
    Warning: this function is expensive and must not be used from within
    the nixpkgs repository.
  </para>
  <para>
    Example usage:

    <programlisting>let
  pkgs = import &lt;nixpkgs&gt; {};
  newpkgs = pkgs.overridePackages (self: super: {
    foo = super.foo.override { ... };
  };
in ...</programlisting>
  </para>

  <para>
    The resulting <varname>newpkgs</varname> will have the new <varname>foo</varname>
    expression, and all other expressions depending on <varname>foo</varname> will also
    use the new <varname>foo</varname> expression.
  </para>

  <para>
    The behavior of this function is similar to <link 
    linkend="sec-modify-via-packageOverrides">config.packageOverrides</link>.
  </para>

  <para>
    The <varname>self</varname> parameter refers to the final package set with the
    applied overrides. Using this parameter may lead to infinite recursion if not
    used consciously.
  </para>

  <para>
    The <varname>super</varname> parameter refers to the old package set.
    It's equivalent to <varname>pkgs</varname> in the above example.
  </para>

</section>

</chapter>