Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "nix-collect-garbage -d --keep-generations 2" #175

Open
domenkozar opened this issue Nov 19, 2013 · 12 comments
Open

Support "nix-collect-garbage -d --keep-generations 2" #175

domenkozar opened this issue Nov 19, 2013 · 12 comments
Assignees
Labels
feature Feature request or proposal

Comments

@domenkozar
Copy link
Member

Would be very useful to be able to keep last X generation when doing garbage collection.

@musteresel
Copy link

Has there ever been any work to implement this feature? What parts of nix would one need to touch?

Adding this for reference:

nix-env --list-generations | head -n -3 | while read num date; do echo "$num"; done | xargs nix-env --dry-run --delete-generations

@mogorman
Copy link
Contributor

mogorman commented Feb 6, 2016

i actually wrote a pr for that #767

@jackjennings
Copy link

This was added in the previously linked PR: #767

@grahamc grahamc closed this as completed Sep 19, 2018
@bbigras
Copy link

bbigras commented Jan 23, 2019

Does nix-collect-garbage has something like --keep-generations?

It seems that the PR added --keep-generations to nix-env. I have no idea how to use it with nix-collect-garbage to clean system stuff.

@alarsyo
Copy link
Contributor

alarsyo commented Sep 9, 2022

Could this be reopened as it would be really useful in nix-collect-garbage? Currently the only way to delete the k last NixOS generations is to run the following command:

nix-env --delete-generations +k --profile /nix/var/nix/profiles/system

making this usage incompatible with all the nix.gc NixOS module options, which only allow passing flags to nix-collect-garbage.

@OleMussmann
Copy link

It could be dangerous for systems that have longer down-times to have their generations scrubbed by time. A buffer of a certain number of generations could prevent that. Please consider re-opening this issue.

@EternityForest
Copy link

If this is already solved, could we get some documentation on how to use it?

@zk395
Copy link

zk395 commented Oct 4, 2023

Would really love to see this kind of feature.

zolodev pushed a commit to zolodev/nix that referenced this issue Jan 1, 2024
zolodev pushed a commit to zolodev/nix that referenced this issue Jan 1, 2024
fix broken link in raspberry pi tutorial
@miku86
Copy link

miku86 commented Mar 17, 2024

Any news on this?

I have a system that gets updated only once every some months.
Using --delete-older-than is not very practical here, because most config changes are at the same day, so I can either delete all of them or none.

@Pandapip1
Copy link

I'd recommend just opening a new issue. It seems unlikely that a maintainer will just stumble across this issue and reopen it.

@Ericson2314 Ericson2314 reopened this Aug 29, 2024
@Ericson2314
Copy link
Member

#9894 should help, and I am sorry to say I am just behind on reviewing that because of other tasks.

@Pandapip1
Copy link

It seems unlikely that a maintainer will just stumble across this issue and reopen it.

I stand corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal
Projects
None yet
Development

No branches or pull requests