aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml')
-rw-r--r--infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml63
1 files changed, 63 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml b/infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml
new file mode 100644
index 000000000000..526803e429ba
--- /dev/null
+++ b/infra/libkookie/nixpkgs/nixos/doc/manual/administration/cleaning-store.xml
@@ -0,0 +1,63 @@
+<chapter xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ version="5.0"
+ xml:id="sec-nix-gc">
+ <title>Cleaning the Nix Store</title>
+ <para>
+ Nix has a purely functional model, meaning that packages are never upgraded
+ in place. Instead new versions of packages end up in a different location in
+ the Nix store (<filename>/nix/store</filename>). You should periodically run
+ Nix’s <emphasis>garbage collector</emphasis> to remove old, unreferenced
+ packages. This is easy:
+<screen>
+<prompt>$ </prompt>nix-collect-garbage
+</screen>
+ Alternatively, you can use a systemd unit that does the same in the
+ background:
+<screen>
+<prompt># </prompt>systemctl start nix-gc.service
+</screen>
+ You can tell NixOS in <filename>configuration.nix</filename> to run this unit
+ automatically at certain points in time, for instance, every night at 03:15:
+<programlisting>
+<xref linkend="opt-nix.gc.automatic"/> = true;
+<xref linkend="opt-nix.gc.dates"/> = "03:15";
+</programlisting>
+ </para>
+ <para>
+ The commands above do not remove garbage collector roots, such as old system
+ configurations. Thus they do not remove the ability to roll back to previous
+ configurations. The following command deletes old roots, removing the ability
+ to roll back to them:
+<screen>
+<prompt>$ </prompt>nix-collect-garbage -d
+</screen>
+ You can also do this for specific profiles, e.g.
+<screen>
+<prompt>$ </prompt>nix-env -p /nix/var/nix/profiles/per-user/eelco/profile --delete-generations old
+</screen>
+ Note that NixOS system configurations are stored in the profile
+ <filename>/nix/var/nix/profiles/system</filename>.
+ </para>
+ <para>
+ Another way to reclaim disk space (often as much as 40% of the size of the
+ Nix store) is to run Nix’s store optimiser, which seeks out identical files
+ in the store and replaces them with hard links to a single copy.
+<screen>
+<prompt>$ </prompt>nix-store --optimise
+</screen>
+ Since this command needs to read the entire Nix store, it can take quite a
+ while to finish.
+ </para>
+ <section xml:id="sect-nixos-gc-boot-entries">
+ <title>NixOS Boot Entries</title>
+
+ <para>
+ If your <filename>/boot</filename> partition runs out of space, after
+ clearing old profiles you must rebuild your system with
+ <literal>nixos-rebuild</literal> to update the <filename>/boot</filename>
+ partition and clear space.
+ </para>
+ </section>
+</chapter>