aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/nix-collect-garbage.xml
blob: 8ff741e2212a758025d8a543df15bf2f490020e6 (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<refentry>
  <refnamediv>
    <refname>nix-collect-garbage</refname>
    <refpurpose>determine the set of unreachable store paths</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>nix-collect-garbage</command>
      <arg><option>--invert</option></arg>
      <arg><option>--no-successors</option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Description</title>

    <para>
      The command <command>nix-collect-garbage</command> determines
      the paths in the Nix store that are garbage, that is, not
      reachable from outside of the store.  These paths can be safely
      deleted without affecting the integrity of the system.
    </para>

  </refsection>

  <refsection>
    <title>Options</title>

    <variablelist>

      <varlistentry>
        <term><option>--invert</option></term>
        <listitem>
          <para>
            Causes the set of <emphasis>reachable</emphasis> paths to
            be printed, rather than the unreachable paths.  These are
            the paths that may <emphasis>not</emphasis> be deleted.
          </para>
        </listitem>
      </varlistentry>
      
      <varlistentry>
        <term><option>--no-successors</option></term>
        <listitem>
          <para>
            Causes <command>nix-collect-garbage</command> not to
            follow successor relations.  By default, if a derivation
            store expression is reachable, its successor (i.e., a
            closure store expression) is also considered to be
            reachable.  This option is always safe, but garbage
            collecting successors may cause undesirable rebuilds later
            on.
          </para>
        </listitem>
      </varlistentry>
      
    </variablelist>

  </refsection>

  <refsection>
    <title>Examples</title>

    <para>
      To delete all unreachable paths, do the following:
    
      <screen>
$ nix-collect-garbage | xargs nix-store --delete</screen>

    </para>

  </refsection>
    
</refentry>