From 87ce378393d11465bf7bbe4e3d4e3ac085d927a4 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Fri, 1 Aug 2025 00:56:19 +1000 Subject: [PATCH] small section on nix garbage collection --- COMMANDS.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/COMMANDS.md b/COMMANDS.md index 25cc6b4..5000bd0 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -6,4 +6,32 @@ nix repl # fenix src FUNC (maybe a different name then src?) fenix repl <<< ":e $FUNC" + +# fenix clean +nix-store --gc # aka nixos-collect-garbage ``` + + + +### Notes +#### Useful Tricks +The path `/nix/var/nix/profiles/per-user/root/channels/` seems to be where +Nix clones the git repos for chosen channels. Could be useful instead +of querying `search.nixos.org`. + +#### "Alias" Commands +The tool `nix-collect-garbage` (as per `man nix-collect garbage`): +> ...is mostly an alias of nix-store --gc ⟨../command-ref/nix-store/gc.md⟩. +> That is, it deletes all unreachable store objects ⟨../store/store-object.md⟩ +> in the Nix store to clean up your system. +> +> However, it provides two additional options, --delete-old ⟨#opt-delete-old⟩ +> and --delete-older-than ⟨#opt-delete-older-than⟩, which also delete +> old profiles ⟨../command-ref/files/profiles.md⟩, allowing potentially more +> store objects ⟨../store/store-object.md⟩ to be deleted because profiles are +> also garbage collection roots. + +> These options are the equivalent of running nix-env --delete-generations +> ⟨../command-ref/nix-env/delete-generations.md⟩ with various augments on +> multiple profiles, prior to running nix-collect-garbage (or just nix-store --gc) +> without any flags.